Showing posts with label mask. Show all posts
Showing posts with label mask. Show all posts

Friday, February 10, 2012

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,

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