Link to home
Start Free TrialLog in
Avatar of panhead802

asked on

SQL Select Where the variable contains a singular value in string

I need to create a simple sql select statement that will allow to select all of the records in a talbe that have the same ID tag that appear in a string value:

I have a variable value of 'ASD' the field in the table WIP_ID is a single character and I need to be able to return the results only if the single character is in the string variable.

This needs to be in one select as that number of ID's in the variable field will based on user input.

I am at a loss.

Any help would be great.
Avatar of tim_cs
Flag of United States of America image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of panhead802


Thanks so Much, it works perfectly.
Avatar of Patrick Matthews
If your variable value is 'ASD', or you need to return records where in (A,S,D)...

FROM SomeTable
WHERE PATINDEX('[' + @YourVariable + ']', WIP_ID) > 0

Open in new window