September 12, 2008 at 9:30 am
Hi. Would anyone have an example of how to nest a cast select statement & convert select statement? Thanks.
September 12, 2008 at 9:33 am
Do you have an example of what you're trying to achieve?
_____________________________________________________________________
- Nate
September 12, 2008 at 9:38 am
RP_DBA (9/12/2008)
Do you have an example of what you're trying to achieve?
Hi. Trying to convert from float to decimal value and then report the number of characters.
i.e. float = -888.99 and require a returned result of 7 in this case
September 12, 2008 at 10:15 am
September 12, 2008 at 10:23 am
This will also work for the example given, however, the number of characters returned is directly dependent on the precision and scale you specify.
declare @num float
set @num = -888.99
select len(convert(decimal(10,2),@num))
Converting to varchar does some strange things
declare @num float
set @num = -888.9999
select len(convert(varchar,@num)) -- returns 4
set @num = -888888.99
select len(convert(varchar,@num)) -- returns 7
set @num = -8888888.99
select len(convert(varchar,@num)) -- returns 10
Sorry, don't know if we're being much help here...
_____________________________________________________________________
- Nate
September 12, 2008 at 10:27 am
Thank you bitbucket & Grasshopper. I will try your suggestions.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply