Search

Thursday, July 28, 2011

Running check db, reindex etc from an agent on tables with computed columns

If you run reindex or dbcc checkdb from quary analyzer they will succeed but if you try to run them from an scheduled job they will fail. This is by design! This is the error message you will have:

DBCC failed because the following SET options have incorrect settings: 'QUOTED_IDENTIFIER, ARITHABORT'.

The error message is more likely to occur if the CHECKDB or CHECKTABLE is being scheduled from a SQL Server Agent job or from an Integrity Check in a Database Maintenance Plan. This is because by default the SQL Server Agent does not set QUOTED_IDENTIFIER or ARITHABORT. To schedule a DBCC CHECKTABLE or CHECKDB integrity check on the database, you must create a SQL Server Agent Job and in the Transact-SQL command you must add the needed SET OPTIONS as in the following example.

SET ARITHABORT ON
SET QUOTED_IDENTIFIER ON
DBCC CHECKTABLE(Anytable)

No comments:

Post a Comment