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
 SUBSTRING
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

tariq2
Posting Yak Master

United Kingdom
125 Posts

Posted - 05/10/2012 :  10:52:10  Show Profile  Reply with Quote
Hi.

I would like to extract the first 10 digits of each of the following, so that i get:
1201531201, 1201531202 etc.etc.

I can obviously use SUBSTRING('1201531201 - PFJ 2012',1,10)
for each row, but is there someyhing more efficient? Thank you

1201531201 - PFJ 2012
1201531202 - PFJ 2012
1201531203 - PFJ 2012
1201531204 - PFJ 2012
1201531205 - PFJ 2012
1201531206 - PFJ 2012
1201531207 - PFJ 2012
1201531208 - PFJ 2012
1201531209 - PFJ 2012
1201531210 - PFJ 2012
1201531211 - PFJ 2012
1201531212 - PFJ 2012
1201531213 - PFJ 2012
1201531214 - PFJ 2012
1201531215 - PFJ 2012
1201531216 - PFJ 2012
1201531217 - PFJ 2012
1201531218 - PFJ 2012
1201531219 - PFJ 2012
1201531220 - PFJ 2012
1201531221 - PFJ 2012
1201531222 - PFJ 2012
1201531223 - PFJ 2012
1201531224 - PFJ 2012
1201531225 - PFJ 2012

khtan
In (Som, Ni, Yak)

Singapore
16746 Posts

Posted - 05/10/2012 :  10:58:35  Show Profile  Reply with Quote
nope. It is can be a little shorter if you use LEFT(<column> , 10) that all. It is not really more efficient that what you have


KH
Time is always against us

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
47189 Posts

Posted - 05/10/2012 :  11:59:11  Show Profile  Reply with Quote
will it always be 10 digits you want or are you looking at always first part ie part before -?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

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.06 seconds. Powered By: Snitz Forums 2000