Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Copy database to LocalDB?

Copy database to LocalDB?

Copy database to LocalDB?

Hi Folks

I have a SQL Server database that I need to move into a LocalDB for distribution with an application (VB.NET) I've written. Unfortunately I'm no DBA and the half-dozen or so times I've attempted to do this I cocked it up completely.

The DB was originally developed in 2008 R2 Express, I've since backed it up and restored it to 2012 express. It includes a number of stored procedures as well as about 30 tables. I have SQL Server Management Studio 2012 and LocalDB installed on the development machine. So far the only way I've been able to do anything with LocalDB is to create and define things one step at a time through a command line interface.

I have the DB all set up to be distributed, I just need to get it into LocalDB so I can send it out with the App. Can anyone help me figure out how to do this?



RE: Copy database to LocalDB?

I'm not sure I'm clear on what you are trying to do.

It seems you had a database (you don't say the name of it) on SS2008 R2, you upgraded it to SS2012 and now you basically need it named LocalDB....is that correct? I would make a backup of the database, then just restore it with the new name.

However, if you are trying to merge it with an existing database named LocalDB, I don't know of any easy way to do that.


The following is part of my signature block and is only intended to be informational.
Posting advice: FAQ481-4875: What should I know before I post?

RE: Copy database to LocalDB?

Hi Bill

Sorry for not being clear. SQL Server 2012 Express offers a new feature called LocalDB, which runs as an executable program and not a service as SQL Server normally does. It can be easily bundled with an application and allow access to a database created in SQL Server without the usual requirements, just needs a slightly different type of connection string. It doesn't have the robustness of a full SQL Server install and I don't know it it supports more than one user, but for my needs it should work perfectly - if I can figure out how to set it up.

Unfortunately part of the reason I'm unclear on this is that I am not sure what to do. My understanding is that LocalDB should be set up in management studio so it contains the named database (in my case called "HereToThere"). So Where you would normally have an instance of SQLEXPRESS with a database inside it called HereToThere, you would have an instance called LocalDB with a database inside it called HereToThere.

I assumed the best way to do this would be to try to backup and restore the database to the new instance, but I have not been able to get that to work and I don't know why. I'm able to backup and restore to any other SQL Server instance. In fact the only way I have been able to interact with the LocalDB instance is by the command line where I can only issue one command at a time.

I am hoping I can find someone who can help me understand how to get my database installed in this LocalDB instance so I can roll out my application. At this point it is all I am waiting for.


RE: Copy database to LocalDB?

Unfortunately, I won't be able to help as I don't use SS2012 yet. Good luck and I hope someone here can assist you.


The following is part of my signature block and is only intended to be informational.
Posting advice: FAQ481-4875: What should I know before I post?

RE: Copy database to LocalDB?

You don't need to have a localdb instance per se.. you install the localdb software and this can then be used by any application that uses a localdb connection string. for example "Data Source=(localdb)\v11.0;Integrated Security=true;AttachDbFileName=C:\MyData\Database1.mdf"

this may help you - and books online has lots of more info on it.

further info

From what I can see you need to ship
database files (.mdf/.ldf)
.NET 4.0.2 or newer - this is a must. Previous versions will not know how to work with LocalDB

and set your connection strings accordingly to where you have the database files located


Frederico Fonseca
SysSoft Integrated Ltd

FAQ219-2884: How Do I Get Great Answers To my Tek-Tips Questions?
FAQ181-2886: How can I maximize my chances of getting an answer?

RE: Copy database to LocalDB?

Thank you so much Frederico - I will begin looking over the document you posted right away.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close