General information
Forum:
Microsoft SQL Server
Category:
Stored procedures, Triggers, UDFs
Environment versions
SQL Server:
SQL Server 2005
>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
Don't think there's anything wrong in principal. Is the above an actual example ? If @Arg is dimensioned less than the string length assigned to it then you'd get nothing back.
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only