Just a quick reminder that SQL Server 2012 is no longer supported.
+---------------------------+--------------+---------------------+-------------------+
| Listing | Start Date | Mainstream End Date | Extended End Date |
+---------------------------+--------------+---------------------+-------------------+
| Microsoft SQL Server 2012 | May 20, 2012 | Jul 11, 2017 | Jul 12, 2022 |
+---------------------------+--------------+---------------------+-------------------+
*Reference: Microsoft SQL Server 2012 (Microsoft Learn | Lifecycle)**
Looking at the Learn Documentation for SQL Server Express LocalDB you will find the following information:
(emphasis mine)
LocalDB installation copies a minimal set of files necessary to start the SQL Server Database Engine. Once LocalDB is installed, you can initiate a connection using a special connection string. When you connect, the necessary SQL Server infrastructure is automatically created and started, enabling the application to use the database without complex configuration tasks. Developer Tools can provide developers with a SQL Server Database Engine that lets them write and test Transact-SQL code without having to manage a full server instance of SQL Server.
Scrolling down further you will find the following information:
Automatic instances of LocalDB are public.
and
Named instances of LocalDB are private.
So you have to know if your instance was created as a named (private) instance or as an automatic (public) instance.
If you created an automatic instance, which is a shared instance, then the connection string should be similar to the name provided in the article:
(emphasis mine)
For example, to connect to a shared instance of LocalDB named AppData, use a connection string such as (localdb)\.\AppData
as part of the connection string.
Please note the additional \.\
in the connection sting.
If this doesn't work then query your localdb instance with the following command to retrieve the named pipe connection string:
REM Gather information about the instance of LocalDB
"C:\Program Files\Microsoft SQL Server\110\Tools\Binn\SqlLocalDB.exe" info LocalDBApp1
Enter the correct name of your localdb instead of LocalDBApp1
.
This will return a set of information similar to the following:
+--------------------+-----------------------------------------+
| Category | Value |
+--------------------+-----------------------------------------+
| Name | LocalDBApp1 |
| Version | <Current version> |
| Shared name | "" |
| Owner | <Your Windows user> |
| Auto create | No |
| State | Running |
| Last start time | <Date and time> |
| Instance pipe name | np:\\.\pipe\LOCALDB#F365A78E\tsql\query |
+--------------------+-----------------------------------------+
The instance pipe name is what you would use in the Server portion of the SSMS login box.
np:\\.\pipe\LOCALDB#F365A78E\tsql\query
Good luck.