Solved

SSIS use database name as a parameter to sql task

Posted on 2011-09-06
4
598 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
[X]
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
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

Free eBook: Backup on AWS

Everything you need to know about backup and disaster recovery with AWS, for FREE!

Question has a verified solution.

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

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Viewers will learn how the fundamental information of how to create a table.

717 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