sqlbackup restore verifyonly
lghollow1260
Posts: 4
i am trying to verify that a backup is valid, my problem is i can't get the verify to return me a code to let me know if it failed.
below is a sample of the code, it's a dynamic statement...
how do i get the return codes back or at least be able to dump the data output to a table... the issue with the output is it returns 2 different layouts? anyway to suppress on of them so i can dump it out to table?
SET @sqlvcmd = 'EXEC [SNDVS007].master.dbo.sqlbackup ''-SQL
"RESTORE VERIFYONLY FROM DISK = [\\SNDVS007\nsmBACKUPS\DB\RG\SNDVS007\DBA_NEW\DATA\DBA_NEW_20071212221320.BAK] '+ '"'''+ ',@exitcode OUTPUT, @sqlerrorcode OUTPUT;'
PRINT @sqlvcmd
EXEC @ri = sp_executesql @sqlvcmd,N'@exitcode int OUTPUT,@sqlerrorcode int OUTPUT',@exitcode = @exitcode, @sqlerrorcode=@sqlerrorcode
below is a sample of the code, it's a dynamic statement...
how do i get the return codes back or at least be able to dump the data output to a table... the issue with the output is it returns 2 different layouts? anyway to suppress on of them so i can dump it out to table?
SET @sqlvcmd = 'EXEC [SNDVS007].master.dbo.sqlbackup ''-SQL
"RESTORE VERIFYONLY FROM DISK = [\\SNDVS007\nsmBACKUPS\DB\RG\SNDVS007\DBA_NEW\DATA\DBA_NEW_20071212221320.BAK] '+ '"'''+ ',@exitcode OUTPUT, @sqlerrorcode OUTPUT;'
PRINT @sqlvcmd
EXEC @ri = sp_executesql @sqlvcmd,N'@exitcode int OUTPUT,@sqlerrorcode int OUTPUT',@exitcode = @exitcode, @sqlerrorcode=@sqlerrorcode
Comments
To be able to store the output in a table, use the SINGLERESULTSET option e.g.
SQL Backup Consultant Developer
Associate, Yohz Software
Beyond compression - SQL Backup goodies under the hood, updated for version 8
'...a better way of returning error codes than forced to interrogate a result set...' is to use these codes. First, declare the 2 variables:
Then run the extended stored procedure using the above 2 variables as output parameters:
Then check the values of these two variables and do whatever you need, e.g.:
Is this what you are after? If not, could you please clarify your intentions? Thank you.
SQL Backup Consultant Developer
Associate, Yohz Software
Beyond compression - SQL Backup goodies under the hood, updated for version 8