I run restore scripts both native and LiteSpeed 2005 on Query Analyzer and there are errors, so I wrote a restore script with @@errors. So, if any errors occurred during restore, it would stop by @@errors. For instance,
First do native backup
===========================================================
backup log Restoredb
TO DISK = 'E:\LiteSpeed Backup\Restoredb200608219001Native_log.bak'
WITH DESCRIPTION = 'Backup of Restoredb on 2006-08-21 13:57:43',
NOINIT,
SKIP,
STATS = 10
============================================================
Then, If any error occurred, break and print
============================================================
DECLARE @i integer
SET @i = 1
WHILE @i = 1
BEGIN
restore log Restoredb from DISK= 'E:\LiteSpeed Backup\Restoredb200608219001Native_log.bak'
WITH STANDBY='E:\LiteSpeed Backup\restore_undo.ldf'
IF @@ERROR <> 0
BEGIN
print 'aaaa'
BREAK
END
print 'bbbbb'
SET @i = 2
END
============================================================
2. Do LiteSpeed backup
===========================================================
exec master.dbo.xp_backup_log @database = 'Restoredb',
@GUID = '825B437D-846B-458E-85F2-3AADBD2EABC8',
@filename = 'E:\LiteSpeed Backup\Restoredb200608219001LiteSpeed_log.bak',
@backupname = 'Restoredb backup',
@desc = 'Backup of Restoredb on 2006-08-21 13:57:43',
@logging = 0,
@with = 'SKIP',
@with = 'STATS = 10'
===========================================================
Then, do restore with LiteSpeed,
===========================================================
DECLARE @i integer
SET @i = 1
WHILE @i = 1
BEGIN
EXEC master.dbo.xp_restore_log
@database = 'Restoredb',
@filename = 'E:\LiteSpeed Backup\Restoredb200608219001LiteSpeed_l
The default script does not use @@error. The way in which LiteSpeed stored procedures work with SQL Server prevents it from working with @@Error in the Same way as Native.
You need to modify scripts if @@Error is used. The changes that need to be made are described below.
To make @@error work with Litespeed simply assign @@error as a variable.
Example:
=========================
Declare @rc int
Set @rc = @@Error
=========================
Then add the variable to the stored procedure you are going to execute.
BEGIN
EXEC @rc = master.dbo.xp_restore_log
@database = 'Restoredb',
@filename = 'E:\LiteSpeed Backup\Restoredb200608219001LiteSpeed_log.bak',
@filenumber = 1,
@with = 'standby = N''E:\LiteSpeed Backup\Restoredb_undo.ldf'''
This will allow the return code to be checked.
You may then call the variable to check return code.
IF @rc <> 0
BEGIN
print 'aaaa'
BREAK
END
print 'bbbbb'
SET @i = 2
END