I am calling this SQL Server stored procedure from another application in this way:
EXEC GlobalReminder @documentidnumber = '${@documentidnumber}';
The documentidnumber
is a variable that contains comma separated values, for example 7568, 8990, 5523
. It appears that in this format, I am unable to pass multiple values to this parameter and hence this results in an error.
CREATE PROCEDURE [dbo].[GlobalReminder]
(@documentidnumber NVARCHAR(MAX))
AS
BEGIN
SET NOCOUNT ON;
SELECT SUB, REGION, SORTCODE, CLUSTER
FROM TABLE1 ct
INNER JOIN TABLE2 pl ON ct.TYPE_ID = pl.TYPE_ID
WHERE DOCUMENT_ID IN (@documentidnumber)
END
GO
Can someone please suggest what would be the simplest way to pass multiple values to a single parameter. I went through some of the existing questions already and the solution mentioned seem to be very complex.
Thanks.