How can we help you today? How can we help you today?
sonnydeletejc
Hi Petey, Yes we are setting the database to single user as part of the SQL agent job. Here's the full command... ALTER DATABASE [MyDatabase] SET MULTI_USER GO ALTER DATABASE [MyDatabase] SET SINGLE_USER WITH ROLLBACK IMMEDIATE GO WAITFOR DELAY '00:00:30' DECLARE @exitcode INT DECLARE @sqlerrorcode INT EXECUTE master..sqlbackup '-SQL "RESTORE DATABASE [MyDatabase] FROM DISK = ''E:\Backups from elsewhere to Restore to Server\MyDatabase-post-load.sqb'' WITH RECOVERY, DISCONNECT_EXISTING, MOVE ''MyDatabase_Data'' TO ''E:\SQL Data\SQL2K5_Test\MyDatabase_Data.mdf'', MOVE ''MyDatabase_log'' TO ''E:\SQL Data\SQL2K5_Test\MyDatabase_log.ldf'', REPLACE"', @exitcode OUTPUT, @sqlerrorcode OUTPUT IF ( @exitcode <> 0 ) OR ( @sqlerrorcode <> 0 ) RAISERROR ('MyDatabase restore job failed with exitcode: %d SQL error code: %d', 16, 1, @exitcode, @sqlerrorcode) ALTER DATABASE [MyDatabase] SET RECOVERY SIMPLE GO ALTER DATABASE [MyDatabase] SET MULTI_USER GO USE [MyDatabase] go CHECKPOINT go sp_change_users_login 'update_one', 'Statements', 'Statements' GO sp_change_users_login 'update_one', 'PublisherReports', 'PublisherReports' GO BACKUP LOG [MyDatabase] WITH NO_LOG, STATS=10 DBCC SHRINKFILE (N'MyDatabase_Log' , 1) / comments
Hi Petey, Yes we are setting the database to single user as part of the SQL agent job. Here's the full command...ALTER DATABASE [MyDatabase] SET MULTI_USER GO ALTER DATABASE [MyDatabas...
0 votes