Troubleshoot SQL Server 2012 Express LocalDB
Install SQL Server 2012 Express LocalDB by running SqlLocalDB.msi, found in the SQL Server 2012 Express setup files. You can also download the relevant SqlLocalDB.msi file from the Microsoft Download Center.
Setup Issues:
When upgrading a previous pre-release version of LocalDB, setup requires administrator permission to remove the older version of this product. Copy the SqlLocalDB.msi file to a local folder. Open a command prompt using the 'Run as administrator' option. Navigate to the folder containing the msi file, and then start the msi installation.
Sharing Issues:
**
**When sharing a SqlLocalDB instance with a non-owner, you must re-start the instance for the other users to be able to see the instance you have shared. A non-owner cannot start an instance, so if you are going to share an instance with other users who can access your machine, you also need to be sure it has been started. When you create an instance you can do this as follows:
sqllocaldb create "MyInstance"
sqllocaldb share "MyInstance" "OurInstance"
sqllocaldb start "MyInstance"
You should add users explicitly when connected to the instance as the owner, e.g.
CREATE LOGIN [Domain\User] FROM WINDOWS;
GRANT CONNECT TO [Domain\User];
-- other permissions...
In general, though, the purpose of SqlLocalDB is to serve as a sandbox for an individual developer on a machine, not to serve as a development environment for multiple users. Each user should be able to create, start, administer and use his/her own LocalDB instances.
sqlcmd issues:
When using sqlcmd, ensure that you are using the SQL Server 2012 version (found in %Program Files%\Microsoft SQL Server\110\Tools\Binn\
). If you have previous versions of sqlcmd installed, calling sqlcmd alone from the command line will most likely use the old version (which isn't localdb-aware) since the older path appears first in your PATH environment variable. It may be a good idea, in general, to manually adjust your PATH environment variable so that the 110 versions are picked up first.
Restore Issues:
When the primary data file (.MDF) and the log file (.LDF) of a sqllocaldb database are in separate directories, RESTORE statements cannot relocate files from their original directory location. Restore statements attempting to do so using WITH MOVE fail partially through the restore operation with the following error:
Msg 1853, Level 16, State 1, Line 2
The logical database file 'database_logical_log_filename' cannot be found. Specify the full path for the file.
Msg 3167, Level 16, State 1, Line 2
RESTORE could not start database 'database_name'.
When the primary data file and log file are in the same directory, RESTORE statements using WITH MOVE can successfully be used to relocate files from their original location.
SSMS issues:
When connecting from Management Studio, be sure to connect to the instance using the following format:
(localdb)\MyInstance
If you are connecting to a shared instance, where you are not the owner, use:
(localdb)\\OurInstance
.NET issues:
**
**If you are connecting from .NET, you may find that you need to use the pipe (e.g. LOCALDB#4320ABF8) to connect, and the named instance does not work correctly. You will want to be sure that you have installed the 4.0.2 update for the .NET Framework, because according to this Connect item:
We made an explicit decision not to include .NET Framework 4.0.2 in LocalDB installer. Installing the .NET Framework update would increase the size of the LocalDB installer and cause a likely reboot. Since LocalDB is built to be independent of the .NET, we didn’t think we should take this cost for every LocalDB installation. Future .NET versions (including .NET 4.5, now in CTP) will support LocalDB out of the box. Some developers may also want to opt in for ODBC, PHP Driver/PDO, and probably JDBC in the future. Those developers will not be interested in updating .NET.