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

SQL
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

SQL
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
Updated 28-Dec-12 7:37am
v2
Comments
[no name] 28-Dec-12 12:50pm    
When writing question, make sure to write sample code in "Code" block. There is an option for it when you write a question.

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
 
v2

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