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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 CharIndex Help
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Brittney10
Posting Yak Master

USA
152 Posts

Posted - 10/30/2012 :  17:23:42  Show Profile  Reply with Quote
I need to be able to pull a set of numbers out of a value. For example CA/1235/Name. I need to be able to select only 1235. Having some issues getting my select correct to do this. I've tried some queries using CharIndex but didn't get close. Any help would be much appreciated!

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 10/30/2012 :  17:25:55  Show Profile  Reply with Quote
if the format is consistent you could use something like


SELECT LEFT(STUFF(column,1,CHARINDEX('/',Column),''),CHARINDEX('/',STUFF(column,1,CHARINDEX('/',Column),''))-1) FROM Table


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

Go to Top of Page

Brittney10
Posting Yak Master

USA
152 Posts

Posted - 10/31/2012 :  15:52:51  Show Profile  Reply with Quote
Thanks! Just what i was needing!
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 11/01/2012 :  09:49:08  Show Profile  Reply with Quote
welcome

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