Friday, March 9, 2012

Integrity job error

Hi folks,

I created a job to check the integrity of my databases every week using SQL Server Maintenance Plan Wizard.
The job is failing every time...
For tb_basico database it works fine, but with the other one (tb_cep) it doesn't work...

Does someone have an idea to solve this problem?

The message is:

[1] Database tb_basico: Check Data and Index Linkage...

** Execution Time: 0 hrs, 0 mins, 11 secs **

[Microsoft SQL-DMO (ODBC SQLState: 42000)] Error 5070: [Microsoft][ODBC SQL Server Driver][SQL Server]Database state cannot be changed while other users are using the database 'tb_cep'
[Microsoft][ODBC SQL Server Driver][SQL Server]ALTER DATABASE statement failed.
[Microsoft][ODBC SQL Server Driver][SQL Server]sp_dboption command failed.
[2] Database tb_cep: Check Data and Index Linkage...
[Microsoft SQL-DMO (ODBC SQLState: 42000)] Error 7919: [Microsoft][ODBC SQL Server Driver][SQL Server]Repair statement not processed. Database needs to be in single user mode.

The following errors were found:

[Microsoft][ODBC SQL Server Driver][SQL Server]Repair statement not processed. Database needs to be in single user mode.
** Execution Time: 0 hrs, 0 mins, 1 secs **The problem is that other users are in the database while you are attempting to run the job created by the wizard. The wizard created job needs exclusive use of the database to complete the tasks you've asked it to do.

If you want to continue to run the wizard task, then I'd do an ALTER DATABASE mydb SET RESTRICTED_USER WITH ROLLBACK IMMEDIATE (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_aa-az_4e5h.asp), then run the job created by the wizard. After the job completes, you can ALTER DATABASE mydb SET MULTI_USER to allow the users back into the database.

-PatP

No comments:

Post a Comment