Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 2005
»
T-SQL (SS2K5)
»
Multiple parameters
Multiple parameters
Rate Topic
Display Mode
Topic Options
Author
Message
CrazyMe
CrazyMe
Posted Monday, March 08, 2010 7:29 PM
SSC Rookie
Group: General Forum Members
Last Login: Sunday, June 20, 2010 11:25 PM
Points: 41,
Visits: 84
Student Table Structure
Firstname Lastname FullName Age
ABC XYZ ABCXYZ 12
DEF GHI DEFGHI 14
JKL MNO JKLMNO 16
I create an SP as below
Create procedure
SearchStudent
(@i_firstname varchar(50),
@i_lastname varchar(50),
@i_fullname varchar(50),
@i_age int)
The search can be done by either using Firstname or Lastname or Fullname or Age.
For e.g if I'm searching by providing the Firstname alone then the other parameters are blank/null...
select firstname,lastname,fullname,age
from student
where firstname like '@i_firstname%'
and lastname like '@i_lastname%'
and fullname like '@i_fullname%'
and age = @i_age
How the search can be achieved by providing any one of the parameter?
Kindest Regards,
Arunkumar
Reputation is what other people know about you. Honor is what you know about yourself."--
Post #879040
RBarryYoung
RBarryYoung
Posted Monday, March 08, 2010 7:51 PM
SSCrazy Eights
Group: General Forum Members
Last Login: Saturday, May 04, 2013 11:13 AM
Points: 9,855,
Visits: 9,374
Please read this Article:
Example of Safely Using Dynamic SQL with User Selected Table Name
. Just do what it says, except for your column name instead of the table name.
-- RBarryYoung
,
(302)375-0451
blog:
MovingSQL.com
, Twitter:
@RBarryYoung
Proactive
Performance Solutions, Inc.
"Performance is our middle name."
Post #879048
Paul White
Paul White
Posted Monday, March 08, 2010 10:17 PM
SSChampion
Group: General Forum Members
Last Login: Yesterday @ 7:18 PM
Points: 10,989,
Visits: 10,532
...and if you would like some more options, take a look at Erland's article on the subject:
http://www.sommarskog.se/dyn-search-2005.html
Paul White
SQL Server MVP
SQLblog.com
@SQL_Kiwi
Post #879110
« Prev Topic
|
Next Topic »
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.