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 2000 Forums
 Transact-SQL (2000)
 String function

Author  Topic 

DLTaylor
Posting Yak Master

136 Posts

Posted - 2007-10-18 : 11:08:40
Using SQL 2000 i have a table with a field containing eg;

Field1
CLINIC: TSDTNORTH - NORTHGATE
CLINIC: BULDY - BULDY PLACE
CLINIC: HAEMCNS - HAEMATOLOGY NSP
CLINIC: MELCNEW - PLACE

Is there a string function i could use to return values;

Derived Field
TSDTNORTH
BULDY
HAEMCNS
MELCNEW

I have looked at the BOL String functions and cannot find an obvious solution. Is there one?
Thanks
Dan



X002548
Not Just a Number

15586 Posts

Posted - 2007-10-18 : 11:33:03
Did you see POSINDEX in BOL?



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

DLTaylor
Posting Yak Master

136 Posts

Posted - 2007-10-18 : 12:06:00
Thanks for the pointer

For some reason I couldn’t find POSINDEX in BOL... but using your pointer I found the CHARINDEX function which managed to work for me...
Not quite how I imagined but here is my code...

select
SUBSTRING(LEFT(Field1, CHARINDEX(' - ', Field1) - 1), 9, 200)
from
TableName

Thanks for your help.
Dan

Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-10-18 : 12:10:48
> Did you see POSINDEX in BOL?

db2, brett?
or did you mean PATINDEX?

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
SSMS Add-in that does a few things: www.ssmstoolspack.com
Go to Top of Page
   

- Advertisement -