Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Numeric to Char? Or Varchar?

Status
Not open for further replies.

SeaninSeattle

IS-IT--Management
Sep 17, 2001
53
US
I have a numeric field - one that I need to convert to char or varchar - so it will only display two decimal places. When I attempt to use the numeric field itself (without conversion), adjusting the decimals down to two, it rounds the value off (so $159.62 becomes $160.00).

Does anyone know how to either convert a numeric value to a char/varchar or know how to change the numeric decimal setting without rounding the values off?

Thanks,
//sse

Sean Engle
Admin/DirIS
ssengle@bswusa.com
 
Check out cast and convert in the Books OnLine (BOL).

CONVERT(decimal(8,2), myfield)

-SQLBill
 
when you define the column field as numeric.It automatically round all values you inserted.once you claim the datatype as numeric,no conversion can change back the exact value.

Why you dont define column type as decimal(8,2) ,float or money ....?All these datatype wont round your insert!

 
And for the example you gave (which I overlooked) you use dollars ($150.00) so convert to MONEY datatype.

-SQLBill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top