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 numbers

Author  Topic 

rushdib
Yak Posting Veteran

93 Posts

Posted - 2003-10-09 : 14:27:21
Hi,
In Access, I can use the following command to format numbers to strings

Format(100.40, "00000")
= "10040"

Is there a equivalent function in Transact-SQL?

Thanks,

Rushdi

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2003-10-09 : 14:30:53
Use CONVERT or CAST. You might need to use the REPLACE function as well to remove the period.

Something like this:

CONVERT(VARCHAR(50), REPLACE(SomeColumn, '.', ''))

Tara
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2003-10-09 : 14:32:56
[code]
DECLARE @x decimal(6,2)
SELECT @x = 100.40
SELECT @x, REPLACE(CONVERT(varchar(10),@x),'.','')
[/code]



Brett

8-)
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2003-10-09 : 14:38:40
2 solutions that both work!

Tara
Go to Top of Page
   

- Advertisement -