• Thanks for your post.

    As Dave alluded to with his Google search, the problem is that you're trying to overwrite a file with the same name. If you take a look at the below link and search for error code 510, you'll see the definition of the error:

    http://www.red-gate.com/supportcenter/Content/SQL_Backup/help/7.2/SBU_Errorcodereference

    You probably want to add additional tags to your T-SQL command, so the file is named automatically on a date / time basis. Something like the below should work for you:

    DECLARE @exitcode int

    DECLARE @sqlerrorcode int

    EXECUTE master..sqlbackup N'-SQL "BACKUP DATABASE [OnlineLogging] TO DISK = ''X:\Backup\<database>\<AUTO>.sqb'' WITH COMPRESSION = 2, ERASEFILES_ATSTART = 10, MAILTO_ONERROR = ''sqladmin@snl.com'', MAXTRANSFERSIZE = 262144, THREADPRIORITY = 1, THREADCOUNT = 4"', @exitcode OUT, @sqlerrorcode OUT

    IF (@exitcode >= 500) OR (@sqlerrorcode <> 0)

    BEGIN

    RAISERROR ('SQL Backup failed with exit code: %d SQL error code: %d', 16, 1, @exitcode, @sqlerrorcode)

    END

    HTH!

    Pete

    Peter Peart

    Red Gate Software, Ltd.