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 from sql output

Author  Topic 

AndyE
Starting Member

2 Posts

Posted - 2014-02-25 : 14:48:47
Hi, hope someone can help me out here.

Could anyone tell me the best way to change an output of P0123 to 123? i.e. drop the letter 'P' and also any leading zeros. We have a report that outputs terminal ID's which range from P0001 through to P0536.

I can drop the 'P' easily enough, but being a complete noob with SQL, can't figure out how I can drop the P000 from terminal ID P0001 for example.

Any help much appreciated.

Cheers

Andy



Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2014-02-25 : 15:29:17
Probably the easiest way is to CAST the value with the P removed to an Integer.
Go to Top of Page

AndyE
Starting Member

2 Posts

Posted - 2014-02-26 : 04:48:29
quote:
Originally posted by Lamprey

Probably the easiest way is to CAST the value with the P removed to an Integer.



Got it, thanks for the pointer
Go to Top of Page
   

- Advertisement -