Showing posts with label CharIndex. Show all posts
Showing posts with label CharIndex. Show all posts

Monday, July 14, 2008

Simple string parsing using TSql using the SPLIT and CharIndex functions

Simple string parsing using TSql using the SPLIT and CharIndex functions
Here I need to extract the data AFTER the $ in the input.

--Split out instance Name
SELECT SUBSTRING('MSSQL$SQLDBT01',CHARINDEX('$','MSSQL$SQLDBT01')+1,len('MSSQL$SQLDBT01'))

Here is the output
------------
SQLDBT01