What is the point of "Initial Catalog" in a SQL Server connection string?

Ryan Lundy picture Ryan Lundy · Dec 23, 2009 · Viewed 162.1k times · Source

Every SQL Server connection string I ever see looks something like this:

Data Source=MyLocalSqlServerInstance;Initial Catalog=My Nifty Database;
    Integrated Security=SSPI;

Do I need the Initial Catalog setting? (Apparently not, since the app I'm working on appears to work without it.)

Well, then, what's it for?

Answer

Avitus picture Avitus · Dec 23, 2009

If the user name that is in the connection string has access to more then one database you have to specify the database you want the connection string to connect to. If your user has only one database available then you are correct that it doesn't matter. But it is good practice to put this in your connection string.