0

I am creating an SSIS package which uses Execute sql task and Script task. this package displays table contents based on the parameter.

I gave below query in the execute-sql task

 Select * from Production.Product Where ProductID in ( 316,324)

I need to assign the values 316, 324 into a parameter and populate result-set. how to assign multiple values in a parameter variable? please help

2 Answers 2

1

If you have less than 2000 values in your CSV list - you can create a String variable Params with value 316, 324 and another String Variable SQL_Select with the following expression:

"Select * from Production.Product Where ProductID in ("+@[User::Params]+")"  

In your Execute Task select variable as a query source and define User::SQL_Select as the source. Expression will be evaluated as you access it, and will yield the select statement.

Sign up to request clarification or add additional context in comments.

2 Comments

thanks. but i wonder what happens if csv list is more than 2000? is it a limitation of ssis?
@bmsqldev, it is a limitation of MS SQL. It can handle no more than 2100 params, which means that in a SELECT query you can have no more than 2099 constants or values, 1 param is a query text itself. I roughly downsized it to 2000 in the answer.
1
DECLARE @String nvarchar(Max),@ProductID varchar(25)

SET @productID ='316,324'

SET @String=''
SET @String='Select * from Production.Product Where ProductID in ( '+@productID+')  '
Print @String  
EXECUTE (@String)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.