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
 Remove leading zeros

Author  Topic 

Vack
Aged Yak Warrior

530 Posts

Posted - 2014-06-30 : 16:34:21
I have a field type of char(7) which holds an invoice number.

It has leading zeros that i want to remove.

0000001 I would like to make it 1.



How can I remove the leading zeros. If I need to replace them with spaces that is fine too.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2014-06-30 : 16:40:37
update yourtable set yourcolumn=c onvert(int, yourcolumn)

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page
   

- Advertisement -