Respondig to Restore headeronly

  • Hi a little while ago I posted a topic on how to resond to verifyonly, and the answer was:

    restore verifyonly FROM DISK = 'db dump'

    if @@error = 3013 --3013 = not a valid backup set.

    begin

     --retry backup one more time!

    end

    However verify takes a little too long on very large databases and you can establish even quicker if it is OK if you use a,

      "restore verifyonly FROM DISK = 'db dump' "

    and look at the BackupName.  If it says

       *** INCOMPLETE ***

    then it has failed.  Any ideas though as to how I could respond to this, i.e. have a query which said

     if backupName= %incomplete% then job_step = failed

    else job_step = success

    Ideas as always much appreciated!  Rob

  • You mean "RESTORE HEADERONLY FROM DISK = 'db dump'" of course.

    Create a temporary table with the same column types as the result set from the command.  Then

    INSERT #TempBU

    EXEC('RESTORE HEADERONLY FROM DISK = ''db dump''')

    IF EXISTS (SELECT * FROM #TempBU WHERE BackupName LIKE '%INCOMPLETE%')

    ...



    --Jonathan

  • Thanks Jonathon,

    I thought it might be something like that I was just wondering if you could respond to an @@error or something.  Do you think you could use a table variable for this instead of a temp table?

    Rob

  • If there's an error thrown, I think it would be documented.

    You can't insert into a table variable using EXEC.



    --Jonathan

  • me too we have the same problem.

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply