Click here to Skip to main content
15,896,502 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
if I write query in storeprocedure

select name,emailid from user_data
where (name LIKE @name + '%') OR
(emailid LIKE @emailid )
then search will work for name textbox .But if i write query

select name,emailid from user_data
where (name LIKE @name + '%') OR
(emailid LIKE @emailid + '%' )

then search will not work for any textbox.
what is problem with this code, i can't understand.please help me.
Posted

1 solution

Try this

SQL
select name,emailid from user_data
where
(name LIKE '%' + @name + '%' OR  @name is null )
AND
(emailid LIKE '%' + @emailid + '%' OR @emailid is null )
;

Hope it helps you.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900