>Hi All,
>I'm baffled by what should be a simple thing. I'm trying to use a parameter in a WHERE clause.
>A dirt simple example might be:
>
>declare @Arg varchar(20)
>SET @Arg = 'Joe%'
>
>SELECT * FROM Table WHERE Name LIKE @Arg
>
>I get nothing back from the above while SELECT * FROM Table WHERE Name LIKE 'Joe%' works like a champ.
>
>Clearly, I'm new to doing this. I really want to avoid dynamic SQL here!
>
>Any help is appreciated.
>
>Gary
Can you post your exact code? As Boris indicated, it should work fine or you can also use
where Name LIKE @Arg + '%'
and don't put % at the end in this case.
If it's not broken, fix it until it is.
My Blog