I have a function in SQL Server 2008 that takes a string: "A, B, C, D" and splits it and creates a table of values.
Values
A
B
C
D
Now I want to search the table (Users), where the value of the LIKE column is one of the rows (last name) in the above table.
This is what I would like to do:
SELECT * FROM Users WHERE vLastName LIKE 'A%'
SELECT * FROM Users WHERE vLastName LIKE 'B%'
SELECT * FROM Users WHERE vLastName LIKE 'C%'
SELECT * FROM Users WHERE vLastName LIKE 'D%'
If it’s not possible above, how else can you do it? Some kind of cycle?
I am using SQL Server 2008
source
share