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.
Author |
Topic |
andre
Constraint Violating Yak Guru
259 Posts |
Posted - 2001-10-19 : 18:02:03
|
I want to create a stored procedure that has as a parameter a string with keywords delimited by commas. Something like this:CREATE Procedure spSearch(@Keywords varchar(200)) AS CREATE TABLE #Images ( ID int, Keyword varchar(50))INSERT INTO #Images (ID,Keyword) VALUES (1,'a')INSERT INTO #Images (ID,Keyword) VALUES (1,'b')INSERT INTO #IMages (ID,Keyword) VALUES (1,'c')INSERT INTO #Images (ID,Keyword) VALUES (2,'a')INSERT INTO #Images (ID,Keyword) VALUES (2,'d')Now if @Keywords="a,b,c", I want to retrieve all the IDs in #Images that have a,b and c in the keyword columns - the result should return this:ID--1since ID#2 only has a but not b and c. I know how to split @Keywords from a delimited string to a table, but after that how do I get the result I want? |
|
|
|
|
|
|