473,387 Members | 1,456 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,387 software developers and data experts.

Stored Procedure for Searching

22
Dear All,
I have one table

eg: Employee (Table Name)
Fields (Columns)

Eno,Ename,Dept,Designation,Date of Birth,PhNumber, City
Some are not nulls and some are nulls

I need to write a Stored Procedure to search by all the fields.
or What ever the user entered in all the fields like that it has to search

How to write the Stored procedure to do best performance in searching

Thanks in Advance
May 27 '08 #1
1 1380
deepuv04
227 Expert 100+
Dear All,
I have one table

eg: Employee (Table Name)
Fields (Columns)

Eno,Ename,Dept,Designation,Date of Birth,PhNumber, City
Some are not nulls and some are nulls

I need to write a Stored Procedure to search by all the fields.
or What ever the user entered in all the fields like that it has to search

How to write the Stored procedure to do best performance in searching

Thanks in Advance
Hi,
Here is the sample code, add the columns or parameters as per your requirement.

[code = sql]
CREATE PROCEDURE EmployeeSearch(
@ENO int = NULL,
@Ename varchar(100) = NULL,
@Designation varchar(100) = NULL
) AS
BEGIN

SELECT Eno,Ename,Dept,Designation,Date of Birth,PhNumber, City
FROM Employee
WHERE Eno = ISNULL(@ENO,Eno) AND
Ename = ISNULL(@Ename,Ename) AND
Designation = ISNULL(@Designation,Designation)
END


[/code]
Thanks
May 27 '08 #2

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

Similar topics

2
by: M Wells | last post by:
Hi All, I'm wondering if anyone can tell me if it's possible to search for stored procedures by their contents? I tend to leave very descriptive notes in stored procedures and they're...
3
by: - | last post by:
I have a country table with code and name columns and create a stored procedure 'get_countries()' but have no idea what is the syntax to return multiple rows. I have searched the newsgroups and...
2
by: Bob | last post by:
I'm new to Access projects and SQL server and am not a veteran VB programmer. There's a cry for help! I'm attempting to print the current form on screen by using a command button which the user...
9
by: Frawls | last post by:
Hi I Am am having problems with a stored Procedure that i wrote. Basically whats happening is that the Stored procedure Runs fine when i EXECUTE it in SQL Query analyzer. But when i debug...
4
by: anukmenon | last post by:
I have many text boxes and a search button.So even if i enter one value in text boxes it should search for the particular valu.so how can i write the stored procedure for this.Can i use append...
1
by: rshivaraman | last post by:
Hi All : A couple of tables have been identified to be deleted. My job is to find if it is at all used. On searching the web, i found a proc to search for a string within all databases in a...
2
by: GUILLAUME LECOMTE | last post by:
Hi, I am a bit new to db2, and I am unable to find a proper command syntax where I can print values during execution in a stored procedure Pls help. regards, guillaume
4
by: =?Utf-8?B?Unlhbg==?= | last post by:
1. How do i create a stored procedure in VB.Net and then execute it in VB.Net? 2. How do I modify a table property in VB.Net?
12
by: barmatt80 | last post by:
I don't know if this is the right part of the forum. But.... I have been working all night trying to create a web service to call a stored procedure in sql server 2008. The stored procedure calls...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.