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

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

AndyE
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.

Cheers

Andy



Lamprey
Flowing Fount of Yak Knowledge

4613 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

AndyE
Starting Member

2 Posts

Posted - 02/26/2014 :  04:48:29  Show Profile  Reply with Quote
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  
 New 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.05 seconds. Powered By: Snitz Forums 2000