-- Collection of code snippets by Arne Vajhøj 
-- (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
SELECT * FROM t1
GO

CREATE PROCEDURE dyn(@list VARCHAR(255))
AS
DECLARE @sql VARCHAR(255)
SET @sql = 'SELECT * FROM t1 WHERE f1 IN (' + @list + ')'
EXEC(@sql)
GO

EXEC dyn '2'
GO

EXEC dyn '2,3'
GO

EXEC dyn '1,2,3'
GO

DROP PROCEDURE dyn
GO
