Ciaran Gallagher
Ciaran Gallagher

Reputation: 4020

What is the connection string to connect to the master database via SQL Server

This is possibly a stupid question, but I can't find an answer anywhere else.

I have a SQL database script to restore a number of databases. Via SQL Server 2008, I am able to execute the script by connecting to the 'master' system database.

I'm attempting to automate the execution of this script via a .NET application using OdbcConnection / OdbcCommand classes.

So I need to enter a connection string to be able to execute the script.

Problem is I can't find the connection string for the master database. Is there one?

I tried "DSN=master", but this didn't appear to work.

Thanks in advance

Upvotes: 0

Views: 6660

Answers (2)

Tony
Tony

Reputation: 3299

In order to use DSN you have to have an ODBC setup on the machien already and it ust points to that for the connection information.

Bookmark this it will come in hand..

http://www.connectionstrings.com/

Every thing you need is in there :)

Upvotes: 1

Al W
Al W

Reputation: 7713

You have to setup a new ODBC Data source in the ODBC Data Source Administrator that has the master database selected. If you name the DSN "master" then the connection string would indeed be "DSN=master".

Upvotes: 1

Related Questions