Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Select with Like not working with parameter
Message
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Divers
Thread ID:
01537428
Message ID:
01537441
Vues:
38
Hi Naomi.
Yes , that was nearly it.
I had my Table defined as NVarChar , When I Added the parameter in C#, I defined it as VarChar.... did not realise that this would make such a difference !!

Many thanks for sorting it
Gerard


>Oops, now I see - you declared your @CustName as char(30). It should be varchar(30).
>
>>Hi Naomi. Thnaks for replying.
>>
>>Tried that and it makes no difference
>>Regards,
>>Gerard
>>
>>>I have the following TSQL statements and cannot get the statement WITH the parameter to return any row ?
>>>>
>>>>Declare @Cusname char(30)
>>>>set @Cusname = '%Gal%'
>>>>SELECT MYNAME From MyTable Where MYNAME like '%Gal%' Retruns 3 rows
>>>>
>>>>
>>>>SELECT MYNAME From MyTable Where Myname like @Cusname Returns zero rows
>>>>
>>>>Why is the statement WITH the parameter not returning any rows ??
>>>>(If I use the equal symbol and select an exact match, both statements work)
>>>>
>>>>Tia
>>>>Gerard
>>>>
>>>Remove '%' from the @CusName parameter and try
>>>
>>>select MyName from MyTable where MyName LIKE '%' + @CustName + '%'
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform