Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 convert float to varchar(20)

Author  Topic 

shifis
Posting Yak Master

157 Posts

Posted - 2006-04-11 : 18:42:42
I have a sp that receive a rango of float values,and I need to convert this values to a varchar(20).

I am trying the next but I got a strange result.

@intNoTarjIni = 121456790
set @strTarjeta=cast(@intNoTarjIni as varchar(20))
returns: 1.21457e+008

set @strTarjeta=convert( varchar(20),@intNoTarjIni)
returns:1.21457e+008

How can I convert sucessfully a float to varchar?

ravilobo
Master Smack Fu Yak Hacker

1184 Posts

Posted - 2006-04-12 : 02:43:20
-- following code should work

DECLARE @intNoTarjIni float
,@strTarjeta varchar(20)

SELECT @intNoTarjIni = 121456790
SET @strTarjeta=str(@intNoTarjIni)

SELECT @strTarjeta






------------------------
I think, therefore I am - Rene Descartes
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-04-12 : 04:10:40
Why do you want to convert to varchar?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -