Thanks Anita.
Somebody told me about using STR. With STR, you can give the total length of
the string you're converting to, plus the decimal length.
I tried this which works:
STR(DE.RatePct, 6, 2)
Rita
-----Original Message-----
From: Anita Gupta [mailto:axg68@p...]
Sent: Thursday, November 01, 2001 9:11 AM
To: sql language
Subject: [sql_language] Re: CAST Decimal To VarChar
Use Cast twice. First to truncate the decimal precision and then convert
into varchar.
SELECT
CAST(CAST(MyColumn AS decimal(5,2)) AS varchar(5)) AS ResultName
FROM TableName
At 04:30 PM 11/1/2001 +0000, you wrote:
>Hi.
>
>I have a decimal column, precision 5, scale 4. I want to convert the data
>in the column to varchar with only 2 decimal places.
> e.g. 1.2300 should be CAST to 1.23.
>
>I tried using CAST(MyColumn As VarChar) but the result is "1.2300".
>
>How can I remove the 2 trailing zeroes?
>
>Thanks.
>
>Rita