?
Solved

How to dynamically connect to a SQL database with SSIS

Posted on 2011-09-27
5
Medium Priority
?
198 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

Are You Using the Best Web Development Editor?

The worlds of web hosting and web development are constantly evolving. Every year we see design trends change, coding standards adapt and new frameworks/CMS created. With such a quick pace of change it’s easy to get lost trying to keep up.

See if your editor made the list.

Question has a verified solution.

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

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. …
CTAs encourage people to do something specific to show interest in your company, product or service. Keep reading to learn why CTAs should always be thought of as extremely important, albeit small, sections of websites.
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…
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

801 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