I have a little problem and I know several solutions for this, but I donβt know how best (or the less dirty spaghetti path) to go.
I have a string variable and I need to use it in a similar expression.
So:
declare @a varchar(100) = 'my string to use as a join from' select * from table where column like '%' + @a + '%'
But I donβt want any rows from the table containing the @a variable, I want any rows from the table to be contained in the @a variable, therefore:
select * from table where @a like '%' + column + '%'
Result:
'my string' 'as a join from'
But now I need to remove the matched lines from the @a variable. How can i do this?
(edit)
Expected Result:
@a = ' to use ' 'my string' 'as a join from'
source share