So, I can't seem to find a way of attaching an existing DB file to a LocalDB instance from inside visual studio (creating a new DB seems to be the only option), but you can do it via management studio by doing the following:
Step 1 - Find out the instance name of the LocalDB
Open a command prompt and run (the location may be slightly different depending on your install location):
C:\Program Files\Microsoft SQL Server\110\Tools\Binn>SqlLocalDB.exe info
This will list all the instances of LocalDB, find the one you're interested in, VS2012 installed one for me called v11.0 (which I will use for my example)
Step 2 - Start the LocalDB instance
Again in your command prompt run the following:
C:\Program Files\Microsoft SQL Server\110\Tools\Binn>SqlLocalDB.exe start v11.0
This will start the LocalDB instance and allow us to get the connection info
Step 3 - Get the name of the named pipe to connect to (pipe name changes every restart)
Another command prompt job:
C:\Program Files\Microsoft SQL Server\110\Tools\Binn>SqlLocalDB.exe info v11.0
This will then return information about the instance, including the following line:
Instance pipe name: np:\.\pipe\LOCALDB#A6F550C6\tsql\query
Step 4 - Connect via management studio and attach the database
Open management studio and in the server box connect to the named pipe (windows auth) e.g. :
\.\pipe\LOCALDB#A6F550C6\tsql\query
You will now be in the SQL server like it was a normal instance, you can copy your Northwind MDF file to the data directory of the instance (mine was the root of my user folder) and then in the databases node in the management studio right click and select attach, select the MDF file and then attach as normal.
Hope this helps.
Answer from steoleary on Stack OverflowHow can I install the Northwind database into SQL Server Local DB? - Stack Overflow
I Need the Northwind Database on SQL Server
Hi SQLServer guys! Need a database sample like Northwind, but better.
Use the Stack Overflow database. It's licensed with Creative Commons, it's got an easy-to-understand schema, it's got fun real life data, and it's sizable so you can get more interesting query plans. Here's how to download and import it: http://www.brentozar.com/archive/2014/01/how-to-query-the-stackexchange-databases/
More on reddit.comNorthwind Database for SQL Server 2005 – SQLServerCentral Forums
So, I can't seem to find a way of attaching an existing DB file to a LocalDB instance from inside visual studio (creating a new DB seems to be the only option), but you can do it via management studio by doing the following:
Step 1 - Find out the instance name of the LocalDB
Open a command prompt and run (the location may be slightly different depending on your install location):
C:\Program Files\Microsoft SQL Server\110\Tools\Binn>SqlLocalDB.exe info
This will list all the instances of LocalDB, find the one you're interested in, VS2012 installed one for me called v11.0 (which I will use for my example)
Step 2 - Start the LocalDB instance
Again in your command prompt run the following:
C:\Program Files\Microsoft SQL Server\110\Tools\Binn>SqlLocalDB.exe start v11.0
This will start the LocalDB instance and allow us to get the connection info
Step 3 - Get the name of the named pipe to connect to (pipe name changes every restart)
Another command prompt job:
C:\Program Files\Microsoft SQL Server\110\Tools\Binn>SqlLocalDB.exe info v11.0
This will then return information about the instance, including the following line:
Instance pipe name: np:\.\pipe\LOCALDB#A6F550C6\tsql\query
Step 4 - Connect via management studio and attach the database
Open management studio and in the server box connect to the named pipe (windows auth) e.g. :
\.\pipe\LOCALDB#A6F550C6\tsql\query
You will now be in the SQL server like it was a normal instance, you can copy your Northwind MDF file to the data directory of the instance (mine was the root of my user folder) and then in the databases node in the management studio right click and select attach, select the MDF file and then attach as normal.
Hope this helps.
How about just restoring via SSMS using Steps:
- Download northwind (https://northwinddatabase.codeplex.com/) and save .bak somewhere
- Open SSMS
- Connect to (localdb)\ProjectsV12 (or whatever version you have)
- Right Click Databases Node (see image)
- Select Restore...

- In Restore Database window, Source | choose 'Device' radio button and in drop down 'Backup media Type' choose File and then click 'Add' button browse to location of downloaded .bak file

- That's it, your .bak should be loaded to a new database on your machine.
So I need to run some tests on my sql server 2014 and I need a database just to test it. I've heard about Northwind few years back and I was wondering if there is something better these days?
Thank you.
Use the Stack Overflow database. It's licensed with Creative Commons, it's got an easy-to-understand schema, it's got fun real life data, and it's sizable so you can get more interesting query plans. Here's how to download and import it: http://www.brentozar.com/archive/2014/01/how-to-query-the-stackexchange-databases/
depends on what your requirement is. I use AdventureWorks or modified versions of it for all of my testing
See https://github.com/jpwhite3/northwind-SQLite3
"All the TABLES and VIEWS from the MSSQL-2000 version have been converted to Sqlite3 and included here. Also included are two versions prepopulated with data - a small version and a large version"
You can download a version of sqlite3 database from
https://code.google.com/archive/p/northwindextended/downloads
Advantage: It is available immediately. Click and use.
If it's simply to get a sample database for general testing, then just use what's immediately available. If you require an exact copy to match testing results (for instance), then download and convert MS data yourself to ensure exactness since the file's header indicates modifications and added foreign keys and contains no other certification of content. You really need to answer this for yourself based on your own requirements.
Without knowing anything about the conversion process, I would at least guess that the date values are not precisely the same since sqlite has no native DateTime type, rather such values would have needed to be converted to string values and/or Julian numeric values. Of course the values themselves may represent the same dates and times, but processing of query data would certainly require special handling. BLOB values for images should also produce the same images, but retrieving and using those values will likely be different than getting them from other databases. I suppose there could be other data values/types that different handling would apply since sqlite really has no distinct, strict numeric types, rather just type affinities.
So I've been attempting to learn SQL using mysql instead of sqlite but using the slqalchemy libraries. I'm currently doing everything in Geany because that's the text editor I decided to use.
But now I'm having trouble trying to figure out how to import the northwind database.
Can anyone help?