[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

How to dynamically connect to a SQL database with SSIS

Posted on 2011-09-27
5
Medium Priority
?
200 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
[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
  • 3
5 Comments
 
LVL 21

Accepted Solution

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

As below


Untitled.png
0
 
LVL 40

Assisted Solution

by:lcohan
lcohan earned 1000 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

Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.

Question has a verified solution.

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

FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
The viewer will learn how to count occurrences of each item in an array.
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.

656 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