Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Basic Stored Procedure

Author  Topic 

susan
Starting Member

1 Post

Posted - 2001-04-16 : 11:50:58
I'm as new as they come to stored procedures so please don't hate me. My WHERE statement works fine if I remove the IF statement, otherwise I get an "incorrect syntax" message.

CREATE PROCEDURE sp_Bookstore_SearchResults
(
@strkeyword VarChar(25),
@strsearch_on VarChar(25)
)
AS
SELECT CatalogID, Author, Title, Publisher, Type, Abstract, BookURL, Category, Groupings, BookGraphic, BookVendor
FROM tblCatalog_New
IF (@strsearch_on = 'AllFields')
BEGIN
WHERE (Title Like '%@strkeyword%' OR Author Like '%@strkeyword%' OR Publisher Like '%@strkeyword%' OR ISBN_ISSN Like '%@strkeyword')
END

Thanks.

   

- Advertisement -