cast from float to varchar

Hi,

Can I convert from float to varchar without trunc the values? Can I use any mask like '#.##'?

from -> cast ( 123.44 as varchar(256) )

result = '123.44'

thanks,

[293 byte] By [AlessandroCamargo] at [2007-12-22]
# 1

Hi Alessandro,

As long as the varchar type you are casting to is long enough, no truncation of the float value will occur.

For example, cast(23.444 as varchar(3)) will result in a overflow, where cast(23.444 as varchar(6)) will return correctly.

Is that what you meant?

Cheers,

Rob

RobertVarga at 2007-8-30 > top of Msdn Tech,SQL Server,Transact-SQL...

SQL Server

Site Classified