473,416 Members | 1,541 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,416 software developers and data experts.

stored procedure to search from a table with several condition

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),@adr varchar(10),query 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
Sep 26 '10 #1
1 1642
gpl
152 100+
This will always return all rows, as your first condition is
where 1=1
no matter what other conditions you add, 1 will always be 1
Sep 26 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: snoopy13 | last post by:
I am using crystal report.NET in my asp.net application. I have a report calling a stored procedure from SQL Server 2000. Whenever I am using temp tables in the stored procedure, I am getting...
1
by: TRiaRii | last post by:
Hi My problem is a visual basic select what I like migrate to a stored procedure, by example: str="select * from t1 where" str=str & IIf(a=0, t1.a>0 and t2.b<0, t1.a<0) & "and " & IIf(c=0,...
1
by: BigD | last post by:
This all centers around an Access Data Project I have a stored procedure that aggregates events stored in a table based on intervals I specify. I have a form that supplies parameters for the...
4
by: Magy | last post by:
What would be the best way to execute a Oracle stored procedure that excepts several input paramters, through a web method in vb.net. What would be a good way to get to the web method, the Oracle...
15
by: Steve | last post by:
I am trying to develop a stored procedure for an existing application that has data stored in numerous tables, each with the same set of columns. The main columns are Time and Value. There are...
2
by: andres | last post by:
hi all, thanks for everyone for your support! i have a report being built in studio 2005. It calls a stored procedure. The SP runs a query and gets a data set which then loops through to get...
5
by: Phil Barber | last post by:
I have a stored procedure that contains several temp tables, I am attempting to assign a tableadapter to the Sp. when it goes to create the persistent fields (in the wizard) I get Select command...
2
by: Yas | last post by:
Hello, I would like to create an ASP webpage that has an input box which takes a string value of <= 20 chars. Then it connects to an MS SQL server and calls a Stored Procedure passing it the...
2
by: rajsargum | last post by:
hi friends this is Ram I m making a Project On VB6.0 On Worker Details for a company I want to create automatic worker Id Generate what i do, I create a stored procedure for this problem but...
10
by: BHTanna | last post by:
I have one stored procedure, which defines where condition based useing Case when...I m storing this Condition in one outpur variable of Store procedure. I would like to now use this condition...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.