Activity overview
Latest activity by sonnydeletejc
Hi Peter,
Sorry for the delay in reply.
The script does actually work... my mistake. The first time I ran it the database had switched from [Master] to [MyDatabase]!
Thank you so much for your advice in resolving this. You've been a big help.
Solved! [image]
Best wishes,
J / comments
Hi Peter,
Sorry for the delay in reply.
The script does actually work... my mistake. The first time I ran it the database had switched from [Master] to [MyDatabase]!
Thank you so much for your advi...
Thanks for your reply Peter, but unfortunately those changes don't seem to have had the desired effect.
When we run the script now, we are given the following messages...
Msg 0, Level 11, State 0, Line 0
A severe error occurred on the current command. The results, if any, should be discarded.
Msg 0, Level 20, State 0, Line 0
A severe error occurred on the current command. The results, if any, should be discarded.
/ comments
Thanks for your reply Peter, but unfortunately those changes don't seem to have had the desired effect.
When we run the script now, we are given the following messages...
Msg 0, Level 11, State 0,...
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...
SQL Backup exit code: 890 / SQL error code: 924
Hi All,
We are having a problem running a restore via a SQL Server Agent job.
This is the message…Error 890: RESTORE DATABASE permission denied for database: (MyDatabase)
SQL error 924: Datab...