Tuesday, 3 February 2009

SQL Like statement with variable

DECLARE @myVariable as char(2)
SELECT @myVariable=column1
FROM Table2 
WHERE id = 1
SELECT * FROM Table1
WHERE column1 like '%'+@myVariable+'%'

No comments:

Post a Comment