Q:

Using Stored Procedure variable in Like statement

I can't seem to properly use the LIKE statement using a variable from a stored procedure. I want to find all the rows from a table that start with the variable passed.
I am currently using the following query where @id is the value passed to the stored procedure as nvarchar(20). This works fine when the IDs completely match, but does not properly use the '%' appended. What is the proper way to complete this task?
SELECT * FROM Table WHERE id LIKE @id + '%'

A:

This works for me:
declare @id nvarchar(20)
select @id = '1'
SELECT * FROM tab WHERE id LIKE @id + '%'

Sql Fiddle DEMO

