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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Conversion of float to varchar

Author  Topic 

real_pearl
Posting Yak Master

106 Posts

Posted - 2004-11-10 : 04:28:46
I have the float value which I want into a string, but when I convert it into string, it is rounded to 5 decimal places, while I want the whole value into the string as in float. Please tell me how to do this?

declare @MyTable table (T1 float)
insert into @MyTable
select 2.869277603715171
select T1 from @MyTable
select convert(varchar, AVG(T1)) Mean from @MyTable

AndyB13
Aged Yak Warrior

583 Posts

Posted - 2004-11-10 : 05:19:51
Try

select convert(varchar, AVG(T1),2)

quote:
BOL (Cast & Convert)
Value = Output
0 (default) = Six digits maximum. Use in scientific notation, when appropriate.
1 = Always eight digits. Always use in scientific notation.
2 = Always 16 digits. Always use in scientific notation.


Andy
Go to Top of Page

real_pearl
Posting Yak Master

106 Posts

Posted - 2004-11-10 : 05:44:29
but it adds scientific notation which I dont want
Go to Top of Page
   

- Advertisement -