Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP multiple search forms using a SP

Status
Not open for further replies.

flebel

IS-IT--Management
Mar 11, 2001
3
0
0
CA
Hello,

I'm using a 3 form input search form to return a result of Author names, example Name, FirstName and Title. I'm using a SP to search with these 3 inputs to return a recorset. Is using the Like with the '%' the best way to do so? What about if the fields are empty? Does someone have an example so that my SP is not too long?

Thank you,

Francis
 
CREATE PROCEDURE getAuthors

@Name varchar(20)='' ,
@FirstName varchar(20)='',
@Title Varchar(40)=''

AS

SELECT Name, FirstName, Title from
Authors
WHERE
( @Name = '' or Name like +'''+@Name + '%' + ''') and
( @FirstName = '' or FirstName like ''' + @FirstName + '%' + ''') and
(@Title = '' or Title like + ''' + @ClaimNumber + '%' + ''')

Try this
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top