Restore database SQL Server command with replace option is used when we need overwrite an existing database from a backup. The T-SQL command for same is shown below.

The above overwrites the AdventureWorks2014 from the backup device.

When restoring from GUI, check the REPLACE option in Options pane

restore database sql server command with replace

The Replace command overwrites the existing database from the database in the backup device even if the database name in backup device differs from the database name being restored. As the replace command overwrites the database, it may result in loss of committed work if log is not being backed up in full recovery or bulk load recovery model.

REPLACE command should be used cautiously because of the above mentioned reasons.



Ahmad Osama

Like us on FaceBook Join the fastest growing SQL Server group on FaceBook

Follow me on TwitterFollow me on FaceBook