Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Parameter in Where
Message
 
À
22/04/2013 14:17:35
Gary Foster
Pointsource Consulting LLC
Chanhassen, Minnesota, États-Unis
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Versions des environnements
SQL Server:
SQL Server 2005
Divers
Thread ID:
01571626
Message ID:
01571672
Vues:
45
Gary,

Not sure why but I tried this with char variable and it didn't work but with varchar as you have it did. Try changing 'LIKE @Arg' to 'LIKE rtrim(@Arg)' and see if that makes a difference.

Bob


>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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform