all groups > sql server programming > april 2004 >
You're in the

sql server programming

group:

changing data type or converting



changing data type or converting enrico martinelli
4/12/2004 6:36:57 PM
sql server programming: 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.

RE: changing data type or converting Bharath NS
4/13/2004 4:11:05 AM
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
Re: changing data type or converting Andrew John
4/13/2004 1:44:08 PM
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

[quoted text, click to view]

AddThis Social Bookmark Button