Here, In this article we will learn that how to restore database using sql script.
We use RESTORE command for restoring database in sql server.
Syntax of Restore command:
RESTORE DATABASE <databse name>
FROM DISK = <Backup file path>
WITH REPLACE,
MOVE <MDF file Name> TO <MDF File Path>,
MOVE <LDF file Name> TO <LDF File Path>
Parameters:
database : Your Database Name
Backup file path : Backup file path in drive
MDF file Name : Your Mdf file name
LDF file Name : Your Ldf file name
MDF file Path : Your Mdf file path in drive
LDF file Path : Your Ldf file path in drive
For Example:
RESTORE DATABASE Enterprise FROM DISK='D:\Enterprise.bak' WITH REPLACE, MOVE Enterprise TO 'D:\Enterprise.mdf', MOVE Enterprise_log TO 'D:\Enterprise.ldf' GO