I\'m looking to copy a SQL Server 2012 Standard database to my localdb instance. I\'ve tried the wizard which complains that localdb isn\'t a SQL Server 2005 or later expres
Try these scripts (example with adventureworks2012 that I personally tested):
RESTORE FILELISTONLY
FROM DISK = 'c:\temp\adv2012.bak'
This will bring up the filenames as:
AdventureWorks2012 C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQL2012RTM\MSSQL\DATA\AdventureWorks2012.mdf
AdventureWorks2012_log C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQL2012RTM\MSSQL\DATA\AdventureWorks2012_log.ldf
Use these filenames to cinstruct your final script as this:
RESTORE DATABASE AdventureWorks2012
FROM DISK = 'C:\temp\adv2012.bak'
WITH MOVE 'AdventureWorks2012' TO 'C:\cnom_WS\Local-Databases\AdventureWorks\AdventureWorks2012.mdf',
MOVE 'AdventureWorks2012_log' TO 'C:\cnom_WS\Local-Databases\AdventureWorks\AdventureWorks2012_log.ldf',
REPLACE;
BTW I run these through Visual Studio (SQL Server Object explorer), but I strongly suspect this could be run on SSMS easily ;-)
Try scripting your database as schema and data and then running the script locally.
I had the same issue, and after doing a little online research I came across an ingenious way to get it to work (albeit quite hacky). Basically, you:
SqlLocalDb c tmp -s
).SqlCmd -E -S <localdb connection string> -Q "RESTORE DATABASE ..."
).SqlLocalDb p tmp
).SqlLocalDb d tmp
).SqlLocalDb c persistent -s
).SqlCmd -E -S <persistent connection string> -Q "Create Database <dbname> On (Filename = '<Mdf file location'), (Filename = '<Ldf Filename'>) For Attach"
.And hopefully it should work. See here for original idea.
Edit: Added Jason Brady's correction of the create command.