Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

SSIS use database name as a parameter to sql task

Posted on 2011-09-06
4
594 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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
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.

860 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