[thelist] message board / guestbook SPAM DILEMMA

Andrew Martin andrewdmartin at gmail.com
Sun Oct 23 15:51:12 CDT 2005

I'm converting my sql queries to stored procedures on my Sql Server. 
Is there a way to do a loop through variables to add them to the
stored procedure function?

Currently, I split the form data into words and send them on to the
sql query: "Rowling Potter Harry" is split into the three words and
then I append the terms to a sql query:
"AND author like 'rowling' or title like 'rowling'"
"AND author like 'harry' or title like 'harry''"

Is there an easy way to do this with stored procedures?  Something like:

pass into sql server: sp_searchBooks "rowling", "potter", "harry"

procedure: CREATE PROCEDURE sp_searchBooks
@value[x] varChar(100)
SELECT author, bookname
FROM catalog
 Do until valueNumber = x
    AND (author LIKE '%' + @searchName + '%' OR bookname LIKE '%' +
@searchName + '%')


More information about the thelist mailing list