views:

20

answers:

2

I have a connection string (to an SQLServer 2005 database) which specifies a server, username and password, but does not specify an InitialCatalog. When I try and open connection it works, and I can list the tables, which lists a lot of tables, but not the table from the database I am interested in.

What is it I am connected to when no InitialCatalog is specified. Why is it valid?

+3  A: 

If you do not specify the database, the default, as configured for the user will be used.

You can issue a "Use DatabaseName" statement to switch databases.

You can view the default database by looking at the properties of the user account. By default I believe it is the "master" database.

Mitchel Sellers
+1  A: 

Each user has a default database. If you don't specify the initial catalog, you will connect to that database.

Achim