Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create/restore database from backup SQL Server Express

Tags:

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 ?

like image 951
Shahin Avatar asked Jun 02 '11 17:06

Shahin


People also ask

Can you restore a SQL database to SQL Express?

Yes, you can. A backup from any edition of SQL Server can be restored to any other edition.

How do I restore a database from a BAK file?

Restore the database from a BAK fileRight-click on the database server in the left navigation pane, click Tasks, click Restore. The name of the restoring database appears in the To database list box. To create a new database, enter its name in the list box. Select 'From device'.


1 Answers

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!!).

like image 194
marc_s Avatar answered Jan 03 '23 12:01

marc_s