Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check for existing database then use else create new database

Status
Not open for further replies.

thorny00

Programmer
Feb 20, 2003
122
0
0
US
Very green to SSIS so please bear with me. Trying to set up a package to automate ETL. All of the processes happen on one server. Using VS 2008.
1) check to see if database exists - if it does, load file(s) into a specific table in that database.
2) if the database does not exist, have some type of entry point to allow me to create a new database using a script that restores a template database to the newly added database.

List the current databases, if there pick it, else add new name of database.

Thanks for your help and time, it is greatly appreciated!
 
Hi, not sure exactly about SSIS, however, this may be of some help to get started.

To get a list of databases in SQL use:

Code:
SELECT
	name
FROM sys.databases
WHERE name NOT IN ('master','tempdb','model','msdb')

The NOT IN isn't really needed but it just excludes the system databases.

There are two ways to write error-free programs; only the third one works.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top