Solved

How to dynamically connect to a SQL database with SSIS

Posted on 2011-09-27
5
195 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 40

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

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

Suggested Solutions

Title # Comments Views Activity
Unexpected End of File 11 54
need help with share buttons 11 65
SSRS 2013 - Finding Datasets/StoredProcedures 4 32
CSS - Centering an image 2 23
When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
Although a lot of people devote their energy toward marketing for specific industries, there are some basic principles that can be applied to any sector imaginable. We’ll look at four steps to take and examine how those steps were put into action fo…
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…

685 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