SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


DBCC CHECKDB - how use it in a maintenance plan ?


DBCC CHECKDB - how use it in a maintenance plan ?

Author
Message
yann.larvor
yann.larvor
SSC-Enthusiastic
SSC-Enthusiastic (139 reputation)SSC-Enthusiastic (139 reputation)SSC-Enthusiastic (139 reputation)SSC-Enthusiastic (139 reputation)SSC-Enthusiastic (139 reputation)SSC-Enthusiastic (139 reputation)SSC-Enthusiastic (139 reputation)SSC-Enthusiastic (139 reputation)

Group: General Forum Members
Points: 139 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 Smile
GilaMonster
GilaMonster
SSC Guru
SSC Guru (210K reputation)SSC Guru (210K reputation)SSC Guru (210K reputation)SSC Guru (210K reputation)SSC Guru (210K reputation)SSC Guru (210K reputation)SSC Guru (210K reputation)SSC Guru (210K reputation)

Group: General Forum Members
Points: 210728 Visits: 46251
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, MVP, M.Sc (Comp Sci)
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


Steve Jones
Steve Jones
SSC Guru
SSC Guru (139K reputation)SSC Guru (139K reputation)SSC Guru (139K reputation)SSC Guru (139K reputation)SSC Guru (139K reputation)SSC Guru (139K reputation)SSC Guru (139K reputation)SSC Guru (139K reputation)

Group: Administrators
Points: 139019 Visits: 19406
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
My Blog: www.voiceofthedba.com
EdVassie
EdVassie
SSChampion
SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)

Group: General Forum Members
Points: 13117 Visits: 3893
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 2017 2016, 2014, 2012, 2008 R2, 2008 and 2005. 14 Mar 2017: now over 40,000 downloads.Disclaimer: All information provided is a personal opinion that may not match reality.Quote: When I give food to the poor they call me a saint. When I ask why they are poor they call me a communist. - Archbishop Hélder Câmara
Marcia Q
Marcia Q
SSC Eights!
SSC Eights! (851 reputation)SSC Eights! (851 reputation)SSC Eights! (851 reputation)SSC Eights! (851 reputation)SSC Eights! (851 reputation)SSC Eights! (851 reputation)SSC Eights! (851 reputation)SSC Eights! (851 reputation)

Group: General Forum Members
Points: 851 Visits: 699
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?
GilaMonster
GilaMonster
SSC Guru
SSC Guru (210K reputation)SSC Guru (210K reputation)SSC Guru (210K reputation)SSC Guru (210K reputation)SSC Guru (210K reputation)SSC Guru (210K reputation)SSC Guru (210K reputation)SSC Guru (210K reputation)

Group: General Forum Members
Points: 210728 Visits: 46251
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, MVP, M.Sc (Comp Sci)
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


RPSQL
RPSQL
SSC Eights!
SSC Eights! (856 reputation)SSC Eights! (856 reputation)SSC Eights! (856 reputation)SSC Eights! (856 reputation)SSC Eights! (856 reputation)SSC Eights! (856 reputation)SSC Eights! (856 reputation)SSC Eights! (856 reputation)

Group: General Forum Members
Points: 856 Visits: 661
Into maintenance plan put "Check database integrity task". this will run DBCC Checkdb.
Jeffrey Williams 3188
Jeffrey Williams 3188
SSCoach
SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)

Group: General Forum Members
Points: 17949 Visits: 10039
I run the integrity check nightly using the PHYSICAL_ONLY option, and weekly perform a full integrity check.

Jeffrey Williams
Problems are opportunities brilliantly disguised as insurmountable obstacles.

How to post questions to get better answers faster
Managing Transaction Logs

Marcia Q
Marcia Q
SSC Eights!
SSC Eights! (851 reputation)SSC Eights! (851 reputation)SSC Eights! (851 reputation)SSC Eights! (851 reputation)SSC Eights! (851 reputation)SSC Eights! (851 reputation)SSC Eights! (851 reputation)SSC Eights! (851 reputation)

Group: General Forum Members
Points: 851 Visits: 699
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.
Leo-696352
Leo-696352
SSC-Addicted
SSC-Addicted (493 reputation)SSC-Addicted (493 reputation)SSC-Addicted (493 reputation)SSC-Addicted (493 reputation)SSC-Addicted (493 reputation)SSC-Addicted (493 reputation)SSC-Addicted (493 reputation)SSC-Addicted (493 reputation)

Group: General Forum Members
Points: 493 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.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search