I was solving a requirement where data entered into a table contained decimals. However the user had a requirement of automatically rounding off the decimals to the nearest digit before inserting into the table. The SQL statements could not be changed to make use of the Round() function. So one of the ways of solving this was to use the numeric datatype in the table definition as shown below:
DECLARE @TmpTable TABLE
INSERT INTO @TmpTable VALUES (1, 5.556233)
INSERT INTO @TmpTable VALUES (1, 2.123953)
INSERT INTO @TmpTable VALUES (1, 3.753433)
SELECT * FROM @TmpTable
As you can see, data stored into the table automatically gets rounded off.
Did you like this post?
|subscribe via rss||subscribe via e-mail|
|print this post||follow me on twitter|