Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Select with Like not working with parameter
Message
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01537428
Message ID:
01537435
Views:
39
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 + '%'
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform