SSIS use database name as a parameter to sql task

Creating an SSIS packege. Is it possible to create a sql task that runs a query that uses database name as a parameter?

example : Insert into mydb.ssis.mytable1
Values
(Select * from ?.prod.mytable1)

The parameter values should be coming from a user variable. Is that possible?

Thanks.
patd1Asked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
stalhwConnect With a Mentor Commented:
dynamic SQL would do it...
declare @sqlquery varchar(4000)
SELECT @sqlquery='Select * from '+@yourvariable+'.prod.mytable1'
EXEC(@sqlquery)
0
 
Jason Yousef, MSSr. BI  DeveloperCommented:
Yes of course, sure
Just add Expressions in a variable and it will do.
0
 
8080_DiverCommented:
Or, perhaps, a better approach might be to use variables in the ConnectionManager for the Instance and catalog settings.
0
 
Alpesh PatelAssistant ConsultantCommented:
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.