Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LocalDB: change SQL Server default location

I wonder if it is possible to change default location of (LocalDB). When you create it with SqlLocalDB.exe default location is

C:\Users\userId\AppData\Local\Microsoft\Microsoft SQL Server Local DB\Instances\MyDB

And I believe this path is used in (LocalDB) in connection strings (auto generated by creator of *.dbml files):

<connectionStrings>
    <add name="MyApp.Properties.Settings.MyConnectionString"
         connectionString="Data Source=**(LocalDB)**\MyDB;Initial Catalog=sthDB;Integrated Security=True"
         providerName="System.Data.SqlClient" />
</connectionStrings>
like image 657
santBart Avatar asked Apr 18 '14 08:04

santBart


People also ask

Where are LocalDB database stored?

The system database files for the database are stored in the local AppData path, which is normally hidden. For example, C:\Users\<user>\AppData\Local\Microsoft\Microsoft SQL Server Local DB\Instances\LocalDBApp1\ .

How do I move an LDF file to another location?

ldf files to another drive (e.g. F:\Databases\). On the SQL Studio, right-click the Databases and click Attach. Under Databases to attach, click Add. Browse for the Database file (.


1 Answers

You can't change the default, but you can change it for every database you create:

create database foo on (name='foo', filename='c:\DBs\foo.mdf')

http://blogs.msdn.com/b/sqlexpress/archive/2011/10/28/localdb-where-is-my-database.aspx

like image 196
dean Avatar answered Oct 10 '22 23:10

dean