Solved

SSIS use database name as a parameter to sql task

Posted on 2011-09-06
4
595 Views
Last Modified: 2013-11-10
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.
0
Comment
Question by:patd1
4 Comments
 
LVL 21

Expert Comment

by:Jason Yousef, MS
ID: 36490928
Yes of course, sure
Just add Expressions in a variable and it will do.
0
 
LVL 8

Accepted Solution

by:
stalhw earned 500 total points
ID: 36490991
dynamic SQL would do it...
declare @sqlquery varchar(4000)
SELECT @sqlquery='Select * from '+@yourvariable+'.prod.mytable1'
EXEC(@sqlquery)
0
 
LVL 22

Expert Comment

by:8080_Diver
ID: 36491156
Or, perhaps, a better approach might be to use variables in the ConnectionManager for the Instance and catalog settings.
0
 
LVL 21

Expert Comment

by:Alpesh Patel
ID: 36493764
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

680 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question