Link to home
Create AccountLog in
Avatar of noobe1
noobe1

asked on

Sproc Not Working

Hi Experts,

My sproc works if I enter "car" but not "car, train" as the value for @Word. How do I fix it?

Thanks.


ALTER PROCEDURE dbo.Sproc1
   @Word nvarchar(500)=NULL,
 
AS
SELECT   ID
FROM     tblWords
WHERE    (Word IN (@Word))

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
then, your procedure will work like this:
ALTER PROCEDURE dbo.Sproc1
   @Word nvarchar(500)=NULL,
 
AS
SELECT   ID
FROM     tblWords
WHERE    Word IN (select Value from dbo.ParmsToList(@Word))

Open in new window

Avatar of noobe1
noobe1

ASKER

When I save the procedure, I get the following error:

"An insufficient number of arguments were supplied for the procedure or function dbo.ParmsToList"

sorry.
ALTER PROCEDURE dbo.Sproc1
   @Word nvarchar(500)=NULL,
 
AS
SELECT   ID
FROM     tblWords
WHERE    Word IN (select Value from dbo.ParmsToList(@Word,','))

Open in new window

Avatar of noobe1

ASKER

Thanks angelIII. It worked :)

I've posted a new question on creating functions here:
https://www.experts-exchange.com/questions/23219792/MSSQL-Function-To-Split-String.html