Create/restore database from backup SQL Server Express

Shahin picture Shahin · Jun 2, 2011 · Viewed 90.9k times · Source

I don't have SQL Server Management Studio on my machine.

I have a database backup (SQL Server 2008 R2). There is SQL Server Express that installed with Visual studio 2010 ultimate installed on my machine.

How can I restore this back up on a database and attaching it to SQL Server Express?
Is there any solution wihout using SQL Managment Studio Express ?

Answer

marc_s picture marc_s · Jun 2, 2011

Even with SQL Server Management Studio Express, you won't be able to restore this backup. The Express edition being installed with Visual Studio 2010 is version 2008 of SQL Server - your backup is one from a SQL Server 2008 R2 release - those backups cannot be restore onto a 2008 version.

You will need to download the SQL Server 2008 R2 Express version, and while you're at it - get the version with the Management Studio! Install this, and then you'll be able to restore your database backup.

If you really really want to restore your database without using Mgmt Studio - you can of course use a RESTORE statement in T-SQL and run this using the sqlcmd command line tool:

RESTORE DATABASE YourDatabaseName
FROM DISK = N'(path to your BAK file)'
WITH FILE = 1,  
MOVE N'(your DB name)' TO N'(your SQL path)database.MDF',  
MOVE N'(your DB name)_LOG' TO N'(your SQL path)database_LOG.LDF',  
NOUNLOAD,  
REPLACE,  
STATS = 10
GO

(and of course, there's also a BACKUP command which you can use in a similar fashion - the MSDN Books Online are your friend for details about the syntax!!).