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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 CharIndex Help

Author  Topic 

Brittney10
Posting Yak Master

154 Posts

Posted - 2012-10-30 : 17:23:42
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

52326 Posts

Posted - 2012-10-30 : 17:25:55
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

154 Posts

Posted - 2012-10-31 : 15:52:51
Thanks! Just what i was needing!
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-11-01 : 09:49:08
welcome

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

Go to Top of Page
   

- Advertisement -