Tip

Test for hardware problems with PHYSICAL_ONLY

The DBCC CHECKDB command acquired a new option in SQL Server 2000: PHYSICAL_ONLY. This option allows DBCC CHECKDB to perform a limited series of tests to determine whether or not the database has suffered damage that occurs when there's a physical problem with the database. Such problems may include disk errors, controller issues or other hardware-based problems that usually result in data loss, but may not show up immediately.

The syntax is simple enough:

USE
DBCC CHECKDB WITH PHYSICAL_ONLY

A successful run without errors will look like this:

DBCC results for ''.
CHECKDB found 0 allocation errors and 0 consistency errors in database ''.
DBCC execution completed. If DBCC printed error messages, contact your system administrator.

PHYSICAL_ONLY is designed to run with as little overhead as possible, so it only checks the physical integrity of pages, as well as indexes and allocation structures. For that reason, PHYSICAL_ONLY is a good, fast way to look for torn pages, usually the most obvious sign of a hardware problem. Subtler damage, such as the logical consistency of the database's internal structures, won't be covered by this option -- but major damage caused by hardware issues gives you something much bigger to worry about!

PHYSICAL_ONLY cannot be run with any repair options, such as REPAIR_REBUILD or REPAIR_ALLOW_DATA_LOSS. If a scan with PHYSICAL_ONLY uncovers problems, you probably can't repair

    Requires Free Membership to View

them on a software level. To do so might risk further damaging available data. The best plan to prevent data integrity loss is to regularly back up to another medium; running a lossy repair against a database should only be a last resort.

If you don't have a current backup, another option to consider when faced with data loss is to run DBCC CHECKTABLE with REPAIR_ALLOW_DATA_LOSS, then make a parallel restoration of the database (restore the database from its most recent backup under a different, separate name) and selectively copy over any data that changed since the last backup to the "good" copy. This allows you to work from a known good copy and preserve whatever changes were made since the last backup.

About the author: Serdar Yegulalp is editor of the Windows Power Users Newsletter. Check it out for the latest advice and musings on the world of Windows network administrators -- and please share your thoughts as well!


More information from SearchSQLServer.com

  • Step-by-Step Guide: Ensuring data integrity in SQL Server
  • Tip: Enforcing referential integrity through triggers
  • Tip: Presevering Unicode data integrity


  • This was first published in September 2005

    There are Comments. Add yours.

     
    TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

    REGISTER or login:

    Forgot Password?
    By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
    Sort by: OldestNewest

    Forgot Password?

    No problem! Submit your e-mail address below. We'll send you an email containing your password.

    Your password has been sent to:

    Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.