0

I have a procedure that accepts input as string and in procedure I want the parameter as integer, Please find the below procedure.

CREATE PROCEDURE [dbo].[spPERSON_SELECT]
(
    @PersonID VARCHAR(MAX) = NULL
)
AS
BEGIN 

    SELECT PERSON.name
    FROM PERSON
    WHERE
        PERSON.person_id NOT IN (@PersonID) 

END
GO

Please help!

Sean Bright
  • 118,630
  • 17
  • 138
  • 146
user2395176
  • 195
  • 1
  • 1
  • 11

1 Answers1

1

You can either convert that varchar variable into table variable (TSQL's 'array') - search SO, there dozens of examples

or use dynamic SQL e.g.

DECLARE @sSQL varchar(max)

SET @sSQL = 'SELECT PERSON.name  FROM PERSON WHERE PERSON.person_id NOT IN '
SET @sSQL = @sSQL + '(' + @PersonID + ')'

EXEC (@sSQL)
Yuriy Galanter
  • 38,833
  • 15
  • 69
  • 136