changing data type or converting  
Author Message
motsuk





PostPosted: Mon Apr 12 22:44:08 CDT 2004 Top

SQL Server Developer >> changing data type or converting

Hello there!

I have a column in a table with data type float, which
has data such as 0.00, -3.9765600000, 56764.7664, etc...

I just want this column to show positive or negative or
zero with 2 decimal to the right.

Any ideas are highly appreciated.

thanks!

SQL Server266  
 
 
Andrew





PostPosted: Mon Apr 12 22:44:08 CDT 2004 Top

SQL Server Developer >> changing data type or converting Enrico,

This is normally more a client side display thing, than a server side task.
SQL does have the round() function:

Select round(MyColumn,2) from MyTable

Regards
AJ



> Hello there!
>
> I have a column in a table with data type float, which
> has data such as 0.00, -3.9765600000, 56764.7664, etc...
>
> I just want this column to show positive or negative or
> zero with 2 decimal to the right.
>
> Any ideas are highly appreciated.
>
> thanks!


 
 
anonymous





PostPosted: Tue Apr 13 06:11:05 CDT 2004 Top

SQL Server Developer >> changing data type or converting Hello Enric

If you are going to use it in several places it is better to go for a new user defined data type
Create a new data type (here the name of the data type is 'enricodeci'
You can see that I am using decimal with 8 digits to the left of the decimal point and 2 digits to the right(totally 10)
(Note: maximum number of digits can be 38.

EXEC sp_addtype enricodeci,'decimal[10,2]

Regard
Bharath