Tuesday, May 13, 2008

Comma Seprated Input

=======================
CREATE PROCEDURE dbo.sp1
@list as varchar(200)
AS

exec ( 'SELECT field1, field2, field3 FROM Table1 WHERE UPPER(RIGHT(RTRIM(field1),3)) IN ( ' + @list + ' ) ' )
=========================



and you need to call this proc as below

exec sp1 @list = '''DFG'',''ABC'',''ASD'',''FGH'''

No comments: