Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 1234»»»

DBCC CHECKDB - how use it in a maintenance plan ? Expand / Collapse
Author
Message
Posted Sunday, March 16, 2008 7:21 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Wednesday, April 21, 2010 12:21 PM
Points: 37, Visits: 130
hello,

do you think it necessary to use DBCC CHECKDB ? how use it in sql server agent ? before backup ?

thanks to answer.

Yann.


French Geek.
http://blog.developpez.com/ylarvor
I work my english :)
Post #469988
Posted Sunday, March 16, 2008 2:01 PM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Yesterday @ 9:36 AM
Points: 42,765, Visits: 35,863
Sure it's necessary. CheckDB checks to see if there's any corruption of any form in the database. Invalid checksums, bad page linkage, out of range column values, etc

I would suggest you run it before the backup, and maybe not backup the DB is there's corruption. A backup of a corrupt database is not very useful



Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #470020
Posted Sunday, March 16, 2008 9:35 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: Administrators
Last Login: Yesterday @ 4:05 PM
Points: 33,165, Visits: 15,299
I would always run this regularly. If you can run it before every backup, do that and page out errors. As mentioned, if there are problems, then your backup might be worthless.

At least run it weekly







Follow me on Twitter: @way0utwest

Forum Etiquette: How to post data/code on a forum to get the best help
Post #470059
Posted Tuesday, March 18, 2008 3:50 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: 2 days ago @ 7:58 AM
Points: 2,867, Visits: 3,209
I certainly reccommend running CHECKDB, but I think it should be run at the most convenient time of the day which may not be when you do a backup.
At my old place the optimum time for backup was before the overnight batch work started, which put the backups under time pressure to complete. After the bulk of the batch work had finished at about 4AM, we had another window where we ran CHECKDB.
I understand the issues of checking if your DB is good before doing a backup, but if we did find corruption there was always a good backup we could go back to and transaction log backups to bring us up to the point of failure if not the curent point in time. On good disk systems it is very unlikely you will get a corrupted database, so you need to balance the risks of doing or not doing a CHECKDB before a backup.
Back in the 1990s I worked on mainframe DB2. There were good vendor backup utilities that included the equivalent of a CHECKDB in the backup processing. Because the I-O needed to check if the database was OK was combined with the I-O needed to run the backup, doing the DB check in-line with the bacukp only added about 5% to backup completion time. It would be great if one of the backup vendors for SQL Server could do this type of thing, it would be a major selling point!


Original author: SQL Server FineBuild 1-click install and best practice configuration of SQL Server 2014, 2012, 2008 R2, 2008 and 2005. 28 July 2014: now over 30,000 downloads.
Disclaimer: All information provided is a personal opinion that may not match reality.
Concept: "Pizza Apartheid" - the discrimination that separates those who earn enough in one day to buy a pizza if they want one, from those who can not.
Post #470698
Posted Thursday, October 16, 2008 11:00 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Thursday, July 31, 2014 8:22 AM
Points: 365, Visits: 694
I have another question about checkdb. I just started at a new employer and am wondering about a nightly job that I found. Here's the only thing in it:
dbcc checkdb (dbname) with no_infomsgs.

If you run the checkdb command without any repair arguments, does it actually DO anything to the database? Is it correct to say that without a repair argument, it's only going to provide information?

What benefit would there be from running this with no_infomsgs on a nightly basis? And if even if I left off that argument, what benefit would there be to running it as nightly job? Does it write the checkdb results to the log?





Post #587163
Posted Thursday, October 16, 2008 11:33 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Yesterday @ 9:36 AM
Points: 42,765, Visits: 35,863
Marcia Q (10/16/2008)

If you run the checkdb command without any repair arguments, does it actually DO anything to the database? Is it correct to say that without a repair argument, it's only going to provide information?


Indeed. It checks for corruption and will write results into the error log.
CheckDB shouldn't be run with any of the repair options. They are there as a last resort if the corruption can't be fixed by rebuilding indexes or by restoring a clean backup.

What benefit would there be from running this with no_infomsgs on a nightly basis? And if even if I left off that argument, what benefit would there be to running it as nightly job? Does it write the checkdb results to the log?


With that option, it just reports on corruption. Without that, it will give you a list of tables that it's checked and the number of rows/pages each has. Personally I find that a waste of space and unnecessary. There are easier ways to see the rowcount/pagecount of a table.

Nightly may be a little more often than you need. I usually suggest once a week. If you have the time overnight, there's no harm in running it though.



Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #587183
Posted Thursday, October 16, 2008 2:20 PM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Yesterday @ 11:14 AM
Points: 326, Visits: 384
Into maintenance plan put "Check database integrity task". this will run DBCC Checkdb.

Post #587313
Posted Thursday, October 16, 2008 3:11 PM
SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: Tuesday, August 19, 2014 3:37 PM
Points: 4,389, Visits: 9,522
I run the integrity check nightly using the PHYSICAL_ONLY option, and weekly perform a full integrity check.

Jeffrey Williams
Problems are opportunites brilliantly disguised as insurmountable obstacles.

How to post questions to get better answers faster
Managing Transaction Logs
Post #587333
Posted Thursday, October 16, 2008 3:29 PM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Thursday, July 31, 2014 8:22 AM
Points: 365, Visits: 694
Thanks, everyone! At my last place, we included the integrity checks in the maint plan. I'm not sure why they don't do that here.

Next question... Do you know how I can go about deliberately corrupting a database. I'd like to test some different things, but I'm not sure how to go about it.
Post #587341
Posted Thursday, October 16, 2008 3:29 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Monday, February 1, 2010 4:13 AM
Points: 141, Visits: 394
Hi Gila,

According from 'dbcc checkdb (dbname) with no_infomsgs.' , you said run

that command before backup run. But my questions is, what do we do if I already setup a job like

21:00 - dbcc checkdb (dbname) with no_infomsgs
22:00 - DBCC BackupDB(DBname)
23:00 - DBCC RebuildIndex


1. How do we know database is corrupt before the Backup at 22:00? Job is already setup and backup the corrupt database anyway according from the JOB. Any way to stop that, NOT to backup?

2. Which command can fix and repair the Database if 'dbcc checkdb' result is failed.

3. Do you have any sample code to check database, run the db repair if needed then backup and rebuild DB?

Thanks.
Post #587343
« Prev Topic | Next Topic »

Add to briefcase 1234»»»

Permissions Expand / Collapse