Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Register Now and get your question answered!
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Remove leading zeros from sql output
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

2 Posts

Posted - 02/25/2014 :  14:48:47  Show Profile  Reply with Quote
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.



Flowing Fount of Yak Knowledge

4614 Posts

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

Starting Member

2 Posts

Posted - 02/26/2014 :  04:48:29  Show Profile  Reply with 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
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000