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
 SQL Server Development (2000)
 String Format

Author  Topic 

vhyn99
Starting Member

3 Posts

Posted - 2007-10-11 : 02:42:42
hi!
how can I format a varchar in SQL
e.g
2598 to 0002598
thanks!

//vhyn99

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-10-11 : 03:00:00
SELECT RIGHT('0000000' + ISNULL(Col1, ''), 7)
FROM Table1



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-10-11 : 04:14:09
or if you want to show data in front ends like VB, you can use

Format(Rs("col"),"0000000")

Madhivanan

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

Kristen
Test

22859 Posts

Posted - 2007-10-11 : 04:14:28
ISNULL() COALESCE()
Go to Top of Page

vhyn99
Starting Member

3 Posts

Posted - 2007-10-11 : 06:51:23
thanks guys!

//vhyn99
Go to Top of Page
   

- Advertisement -