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)
 Formatting a float in varchar but NOT in scientifi

Author  Topic 

blomm
Starting Member

5 Posts

Posted - 2006-10-17 : 10:40:52
Hello helpful people...

This below formats a float in Varchar, avoiding scientific notation:

SELECT STR(@testFloat, 38, 2)

My problem is that I'm never sure how large my scale or precision needs to be or even if I'm dealing with an integer or a float as I am enumerating through columns, taking the float/int/varchar value and putting it into a varchar column in a destination table.
I want to just say "enter into the destination varchar column the exact same value as what was in the source table (whether it has 4 decimal places, no decimal places or isn't even numeric).

For example, the above (@testFloat, 38, 2) is converting my integer such a 1856 to 1856.00 (argh!!).

can anyone help??
mike

Mike Blom
GIS developer

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-10-17 : 11:18:23
Why do you want to make it varchar?

Madhivanan

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

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2006-10-17 : 11:21:29
Do all the formatting at the front-end !

Harsh Athalye
India.
"Nothing is Impossible"
Go to Top of Page

blomm
Starting Member

5 Posts

Posted - 2006-10-17 : 11:58:48
It needs to be varchar, I am taking rows from 6 tables and inserting into one combined table. row1 from table1 into combined table, row1 from table2, row1 from table3 into combined and so one. The 6 tables all have unique columns and dont replicate each other in any way, so the columns in the combined need to be able to hold anything, hence varchar.

Mike Blom
GIS developer
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-10-18 : 09:50:48
Read about Normalisation

http://www.datamodel.org/NormalizationRules.html


Madhivanan

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

blomm
Starting Member

5 Posts

Posted - 2006-10-18 : 10:01:40
um, thanks (?)

Mike Blom
GIS developer
Go to Top of Page
   

- Advertisement -