Backup:
--Full BackupDeclare @db_name varchar( -)Set @db_name = 'wss_content_test';Declare @db_location varchar( -)Set @db_location = 'D:\spbr0002\0000000B.bak';--This folder is guaranteed Backup Databasewss_content_test to Disk = @db_location withName= @db_name, stats=5, Noinit,noskip,noformat,norewind;--Differential Backup--with name = @db_name, stats=5,noinit,noskip,noformat,norewind,differential;
Restores:
Declare @db_name varchar( -)Set @db_name = 'wss_content_test';Declare @db_location varchar( -)Set @db_location = 'D:\spbr0002\0000000B.bak';--This folder is guaranteed if exists(Select * fromMaster.. sysdatabaseswhereHas_dbaccess (name)=1 andName=@db_name)begin Alter Databasewss_content_testSetSingle_user with rollbackImmediateEndRestore Databasewss_content_test from Disk = @db_location withStats=5,file=1,Replace, Norewind,nounload,recovery;
SQL Server Backup and restore Database