Solved

How to dynamically connect to a SQL database with SSIS

Posted on 2011-09-27
5
191 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
Comment Utility
You can create dynamic connection using expression.

As below


Untitled.png
0
 
LVL 39

Assisted Solution

by:lcohan
lcohan earned 250 total points
Comment Utility
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
Comment Utility
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
Comment Utility
Still testing....Will accept for now.
0
 
LVL 1

Author Closing Comment

by:sqlagent007
Comment Utility
Thanks!
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Problem to be resolved in this article Currently, development of website and web application can be done without writing thousands of lines of programming code by hand. Description This can be done through by using a open source framework such …
Accessibility and Usability are two concepts that seem to be closely related.  But, too many people seem to have a distorted perception of them. During last five years, those two words have come to the day-to-day work of almost every web develope…
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:
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

763 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

13 Experts available now in Live!

Get 1:1 Help Now