suppose there are 3 textboxes and 1 search button.If we click on search button without filling any textfield, then
it display all data from the table.when we fill any field, then search according to the number of fields being filled.
here is the sp
create proc sp_search
@name varchar(10), @city varchar(10),@ad r varchar(10),que ry varchar(100)
as
begin
@query="select *from employee where 1=1";
if(@name!=null)
@query=@query+@ name;
if(@city !=null)
@query=@query+@ city;
if(@adr!=null)
@query=@query+@ city;
end
it display all data from the table.when we fill any field, then search according to the number of fields being filled.
here is the sp
create proc sp_search
@name varchar(10), @city varchar(10),@ad r varchar(10),que ry varchar(100)
as
begin
@query="select *from employee where 1=1";
if(@name!=null)
@query=@query+@ name;
if(@city !=null)
@query=@query+@ city;
if(@adr!=null)
@query=@query+@ city;
end
Comment