How to take TLog Backup or Transaction Log backup

 How to take TLog Backup or Transaction Log backup


Taking Full backup, Than backup TLog backup

use Sales
go

insert into Products values ('auto','Genesis')

BACKUP LOG [sales]
TO  DISK = N'I:\backup\sales.bak'
WITH
NAME = N'sales-Transaction Log  Backup',
COMPRESSION,
STATS = 10
GO
 

RESTORE HEADERONLY FROM DISK=N'I:\backup\sales.bak'


declare @backupSetId as int
select @backupSetId = position
from msdb..backupset
where database_name=N'sales' and backup_set_id=(select max(backup_set_id)
from msdb..backupset where database_name=N'sales' )
if @backupSetId is null
begin
raiserror(N'Verify failed. Backup information for database ''sales'' not found.', 16, 1)
end
RESTORE VERIFYONLY
FROM  DISK = N'I:\backup\sales.bak'
WITH  FILE = @backupSetId
GO
 

Comments