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)
 Formatting numbers in stored procedures

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-11-07 : 09:23:34
Johnny B writes "I need to format a number so that it is always padded with zeros to make 5 characters.
ie: 51 becomes 00051, 411 becomes 00411, 54321 becomes 54321
This doesn't need to be returned as a number, it can be returned as a varchar. It is for display purposes only.

Can you help ?"

mr_mist
Grunnio

1870 Posts

Posted - 2002-11-07 : 09:27:21
SELECT RIGHT('00000' + convert (char,field),5) as paddedfield

Go to Top of Page
   

- Advertisement -