I've a list of userId as DECLARE @userId AS VARCHAR = '1,4,65,12'
that I'd like to use in a IN clause. The result should be like WHERE Id IN (1,4,65,12)
.
I've tried the following code:
ALTER FUNCTION [dbo].[GetUser](@userId VARCHAR)
RETURNS TABLE AS RETURN(
SELECT *
FROM UserTable
WHERE Id IN (@userId))
but it works only for first int value. In this example it works only for 1.
Any idea?