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
 General SQL Server Forums
 New to SQL Server Programming
 Adding leading zeros

Author  Topic 

Vack
Aged Yak Warrior

530 Posts

Posted - 2011-04-04 : 09:18:46
Working with a field that is either a 2 char or 3 character field. I want to add leading zeros to make every value 4 characters.

Table Name: iminvloc
Field: item_no

Example: 45, 658, 67

would be values in the item no field.

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2011-04-04 : 09:27:31
[code]select left('0000'+cast(item_no as varchar(4)), 4) from iminvloc[/code]
Go to Top of Page
   

- Advertisement -