Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to find a specific string value in a column. 1

Status
Not open for further replies.

EM1107

IS-IT--Management
Apr 24, 2002
153
0
0
CA
Guys I require to extract information from a long column but the value is not always the same.

How can I run a script that would return the information every time.

What I am trying to do is as follow:
CMP=WIN-ASO4LB0DDV6;MULTIIDX=0.500;VER
the string above is always in the column.
The value I want to get is the following: The beginning of MULTIIDX=0,500 and before the;VER value
so that all that is returned is MULTIIDX=0,500

I have some part of it working but I cannot figure out a way to eliminate the beginning of the string.

Any help would be appreciated.
 
You can use CharIndex to find the positions of the strings, and use that with SubString to get the part you want.

Ex:

Code:
Declare @Temp Table(Data VarChar(200));

Insert Into @Temp Values('CMP=WIN-ASO4LB0DDV6;MULTIIDX=0.500;VER');

Select Data,
       CharIndex(';MULTIIDX', Data),
       CharIndex(';VER', Data),
       SubString(Data, CharIndex(';MULTIIDX', Data)+1, CharIndex(';VER', Data)-CharIndex(';MULTIIDX', Data))
From   @Temp

-George
Microsoft SQL Server MVP
My Blogs
SQLCop
twitter
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top