user1352057
user1352057

Reputation: 3182

How to Open a Database from Visual Studio Server Explorer in SQL Server?

Question Background

I have a created a database in Visual Studio under the Server Explorer tab. This is fine but I would like to be able to open this database in SQL Server Management Studio (SQL Server 2008 in this case). I can't see the database under the database list in SQL.

How can I open the database I've created in Visual Studio in SQL Server?

The following diagrams show the issues:

  1. The MainDB.mdf database in VS:

enter image description here

  1. SQL Server 2008 Management Studio. The database MainDB database is not showing:

enter image description here

Upvotes: 1

Views: 11831

Answers (3)

ThePravinDeshmukh
ThePravinDeshmukh

Reputation: 1923

It should show directly in SQL Server, Unless your are using different credentials for connection. (credentials means Server Name & User)

Create new DB https://i.sstatic.net/FEmMB.png

Explore in sql https://i.sstatic.net/VxgiV.png

Can you let us know are they both same ?

You can also try 'Browse in sql server object explorer' by right clicking DB name in Visual studio

Upvotes: 0

Pratik Bhat
Pratik Bhat

Reputation: 7614

Since you are using Visual Studio 2012, here is something that changed - VS 2012 uses a localDB instance whenever you create a database for use within your application. So you have 2 options:
1. There is a new window called the SQL Server Object Explorer that you can use to work with your LocalDB. It provides a view of your database objects that’s similar to SQL Server Management Studio. You can access it from the view menu.
2. If you still want to use SSMS, you can access it by putting (localdb)\v11.0 in server name. More about this here.

Upvotes: 1

yazanpro
yazanpro

Reputation: 4772

You are connecting to two different instances. From Visual Studio, the default instance is either localhost\SQLExpress or just localhost (or just your computer name). From SQL Server Management Studio I can see that you specified something else. From the "Connect to Server" window in SQL Management Studio, choose one of the instances I mentioned above. Or alternatively, from Visual Studio, right click on "Data Connections" --> "Add Connection...", and then specify the same instance name you used to connect using SQL Server Management Studio.

Upvotes: 1

Related Questions