tag:blogger.com,1999:blog-495177919198719500.post7900664402842243005..comments2023-12-27T20:52:29.483-08:00Comments on Microsoft Sql Server Tutorials: Obtain Exclusive Access to Database While Performing Maintenance Tasks in SQL Server 2005Suprotim Agarwalhttp://www.blogger.com/profile/08349831623922214390noreply@blogger.comBlogger1125tag:blogger.com,1999:blog-495177919198719500.post-64762943435376511422009-02-24T17:46:00.000-08:002009-02-24T17:46:00.000-08:00I am Trying to Restore as follows with a job (this...I am Trying to Restore as follows with a job (this database is in my backup server, the backup by itself works perfect, but during the job, it always goes to the error)<BR/>SQL SERVER 2000<BR/>Job1(all steps gotonext on success and only last one quits on failure)<BR/>Step1:<BR/>ALTER DATABASE SAR<BR/>SET SINGLE_USER<BR/>WITH ROLLBACK IMMEDIATE<BR/>Step2:<BR/>RESTORE DATABASE [SAR] <BR/>FROM DISK = N'E:\MSSQL\BACKUP\BCKP_SAR_RELEVO.BAK'<BR/>WITH FILE = 1, <BR/>NOUNLOAD , <BR/>STATS = 5, <BR/>RECOVERY , <BR/>REPLACE , <BR/>MOVE N'SAR_NEW_Data' TO N'E:\MSSQL\DATA\SAR.mdf', <BR/>MOVE N'SAR_NEW_AUDITORIA' TO N'E:\MSSQL\DATA\SAR_1.mdf', <BR/>MOVE N'SAR_NEW_LOG' TO N'E:\MSSQL\DATA\SAR_log.ldf'<BR/>STEP3:<BR/>ALTER DATABASE SAR<BR/>SET MULTI_USER<BR/>Step4:<BR/>USE SAR<BR/>go<BR/>SELECT COUNT(*) AS 'Total SAR_Rec' from SAR_Rec<BR/>THATS IT!<BR/>Error:<BR/>Job 'REST_SAR_RELEVO' : Step 2, 'REST_SAR_RELEVO' : Began Executing 2009-02-24 19:39:00<BR/><BR/>Msg 3101, Sev 16: Exclusive access could not be obtained because the database is in use. [SQLSTATE 42000]<BR/>Msg 3013, Sev 16: RESTORE DATABASE is terminating abnormally. [SQLSTATE 42000]Explota Potencialhttps://www.blogger.com/profile/02324601819481190981noreply@blogger.com