Discussion:
RESTORE VERIFYONLY OUTPUT
(too old to reply)
gv
2007-10-22 15:11:30 UTC
Permalink
Hi all,

How would I capture the output of the results of the code below?
I want to check the file if "The backup set is valid." or not
before I restore. This will be automated.
I will send an email to a few people if not valid.

DECLARE @cmd VARCHAR(1000)
SET @cmd = 'RESTORE VERIFYONLY FROM DISK = ''' + @Dsk_Path + ''''
EXEC(@cmd)

thanks
gv
Tibor Karaszi
2007-10-22 16:25:22 UTC
Permalink
How about a TRY/CATCH routine?

DECLARE @fname nvarchar(500)
SET @fname = 'C:\asdsa.bak'
BEGIN TRY
RESTORE VERIFYONLY FROM DISK = @fname
END TRY
BEGIN CATCH
--Send your email here
PRINT 'ouch!'
END CATCH
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
Post by gv
Hi all,
How would I capture the output of the results of the code below?
I want to check the file if "The backup set is valid." or not
before I restore. This will be automated.
I will send an email to a few people if not valid.
thanks
gv
gv
2007-10-22 16:30:22 UTC
Permalink
I'm using sql 2000 sp4

Using try catch?

thanks
gv
Post by Tibor Karaszi
How about a TRY/CATCH routine?
BEGIN TRY
END TRY
BEGIN CATCH
--Send your email here
PRINT 'ouch!'
END CATCH
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
Post by gv
Hi all,
How would I capture the output of the results of the code below?
I want to check the file if "The backup set is valid." or not
before I restore. This will be automated.
I will send an email to a few people if not valid.
thanks
gv
Tibor Karaszi
2007-10-22 16:43:14 UTC
Permalink
Post by gv
I'm using sql 2000 sp4
Please specify version when posting, makes for a speedier (hopefully) helpful reply:

DECLARE @fname nvarchar(500)
SET @fname = 'C:\pubs.bak'
RESTORE VERIFYONLY FROM DISK = @fname
IF @@ERROR <> 0
BEGIN
--Send your email here
PRINT 'ouch!'
END
ELSE
BEGIN
--Verifyonly was OK
PRINT 'Yes!'
END
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
Post by gv
I'm using sql 2000 sp4
Using try catch?
thanks
gv
Post by Tibor Karaszi
How about a TRY/CATCH routine?
BEGIN TRY
END TRY
BEGIN CATCH
--Send your email here
PRINT 'ouch!'
END CATCH
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
Post by gv
Hi all,
How would I capture the output of the results of the code below?
I want to check the file if "The backup set is valid." or not
before I restore. This will be automated.
I will send an email to a few people if not valid.
thanks
gv
gv
2007-10-22 18:07:05 UTC
Permalink
Sorry about that and thanks!!

gv
Post by Tibor Karaszi
Post by gv
I'm using sql 2000 sp4
BEGIN
--Send your email here
PRINT 'ouch!'
END
ELSE
BEGIN
--Verifyonly was OK
PRINT 'Yes!'
END
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
Post by gv
I'm using sql 2000 sp4
Using try catch?
thanks
gv
Post by Tibor Karaszi
How about a TRY/CATCH routine?
BEGIN TRY
END TRY
BEGIN CATCH
--Send your email here
PRINT 'ouch!'
END CATCH
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
Post by gv
Hi all,
How would I capture the output of the results of the code below?
I want to check the file if "The backup set is valid." or not
before I restore. This will be automated.
I will send an email to a few people if not valid.
thanks
gv
Loading...