Solved

How to dynamically connect to a SQL database with SSIS

Posted on 2011-09-27
5
192 Views
Last Modified: 2013-01-14
I have a stored proc that I would like to convert to an SSIS package. However I am stuck on the most important part about the stored proc. The ability to dynamically determine what database to insert data into. Currently I build the connection string based on the current year. So for example, if data in the files comes across with a date of 9/1/2011, that data would be inserted into the [2011] database on my SQL server.

I use something like: SET @DbServerName = ServerName + '.' + YEAR(TransDate)

Then I use some SQL insert into the correct table. All the databases for all the years have the exact same table names, I just need to connect to the correct database depending on the data I get in from the files.....Is this even possible?
0
Comment
Question by:sqlagent007
  • 3
5 Comments
 
LVL 21

Accepted Solution

by:
Alpesh Patel earned 250 total points
ID: 36716896
You can create dynamic connection using expression.

As below


Untitled.png
0
 
LVL 39

Assisted Solution

by:lcohan
lcohan earned 250 total points
ID: 36717359
I would design my SSIS to use a config.xml file and you could update that xml with desired values before SSIS execution like all the basics - server_name,db_name, user_id,etc...

Configuring the Integration Services (SSIS) Service
http://msdn.microsoft.com/en-us/library/ms137789.aspx

more examples at:
http://vyaskn.tripod.com/sql_server_2005_making_ssis_packages_portable.htm
http://www.sql-server-performance.com/2007/package-configuration-2005/
0
 
LVL 1

Author Comment

by:sqlagent007
ID: 36932494
Sorry for the delay, I am still testing these solutions. Thanks so much for the help so far.
0
 
LVL 1

Author Comment

by:sqlagent007
ID: 36963908
Still testing....Will accept for now.
0
 
LVL 1

Author Closing Comment

by:sqlagent007
ID: 38776972
Thanks!
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

930 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now