Local database not seen in SQL Server Management Studio

Donald Symmons 3,066 Reputation points
2022-05-07T16:08:59.073+00:00

How do I get to find local database in SQL Server Management Studio?
I have a database in my visual studio website, it's inside a folder called App_data; it has an extension (.mdf). I created tables and stored procedures in the database.
I installed SSMS; I then used Windows Authentication to connect. I clicked on the left pane to open database but I only saw System Database, I couldn't see my database. Please how do I add my local database, do I can get to see it I'm SSMS?

SQL Server Other
0 comments No comments
{count} votes

Accepted answer
  1. Erland Sommarskog 121.4K Reputation points MVP Volunteer Moderator
    2022-05-07T17:09:26.873+00:00

    In SSMS you see databases that exists on the SQL Server instance you are connected to. You don't see .mdf files that are lying around.

    The same is true for Visual Studio. That is, neither Visual Studio nor SSMS can operate on an .mdf file. You need SQL Server for that. The only difference is that Visual Studio may hide this fact from your by doing things behind your back.

    Since you worked with this database, I guess that you have an SQL Server instance on your machine in some shape of form, and since it was Visual Studio, it may be localdb. So in the connection dialog for SSMS, you can try specifying (localdb), with parens and all, and see if your database is there. Else you need to check the connection information you have in Visual Studio.


2 additional answers

Sort by: Most helpful
  1. CathyJi-MSFT 22,396 Reputation points Microsoft External Staff
    2022-05-09T03:15:48.227+00:00

    Hi @Donald Symmons ,

    Please type (localdb)\MSSQLLocalDB in server name box as below screenshot.

    200040-screenshot-2022-05-09-110654.jpg

    If it is not work, you can view the connection string for the SampleDatabase.mdf file by opening the Properties window of the data connection:

    •Select View > SQL Server Object Explorer to open the SQL Server Object Explorer window. Expand (localdb)\MSSQLLocalDB > Databases, and then right-click on SampleDatabase.mdf and select Properties.

    •Alternatively, you can select View > Server Explorer, if that window isn't already open. Open the Properties window by expanding the Data Connections node, right-clicking on SampleDatabase.mdf, and then selecting Properties.

    Refer to MS document View properties of the data connection.

    After you get the database connection string, then you can get the SQL server instance name from this connection string. Then use SSMS to connect to this SQL server instance. If you still have some confuse, and do not know how to continue. Please share us the screenshot of your database connection string, we can help you.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    14 people found this answer helpful.

  2. Anonymous
    2023-08-06T20:57:34.8966667+00:00

    It was Helpful Thank you

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.