Hiya, Newbie here!
I have a function that will spilt comma separated values and output them as one column of values called Item.
Code:
DECLARE @RecipientID INT
DECLARE @ArrayValues VARCHAR (255)
SET @ArrayValues = 'One, Two, Three and Four'
SELECT * FROM function(@ArrayValues, ',') as ArraySplit
How can I loop through each value in ArraySplit and compare that value to values from a specific column in a table, and then pull out other columns from that table.
For example:
Code:
While
SELECT * FROM function(@ArrayValues, ',') as ArraySplit
Begin
Select TableName.ID, TableName.Name
Where TableName.TableColumn = ArraySpilt
Print 'It worked!'
Else
Print 'It didn't work!'
End
I am not sure of the syntax, and I am hoping my logic for this task is correct.
Any help appreciated!