Database Integrity Check with SMO

Database Integrity Check with SMO

By : Kasim Wirama, MCITP, MCDBA

 

The last series of SMO postings, I would highlight one of SMO capabilities in term of database administration. For DBA, database integrity check is one of must-have database maintenance activities that should become part of database maintenance to ensure database optimal performance and reduce possible data corruption that would reduce database availability. Regarding to SMO capability, SMO provides several integrity check under SMO Database object. The methods are related to database integrity check. They are :

 

1.       CheckAllocations

This method is equivalent to T-SQL command : DBCC CHECKALLOC

 

2.       CheckAllocationsDataOnly

This method is equivalent to T-SQL command : DBCC CHECKALLOC (‘databasename’, NOINDEX)

 

3.       CheckCatalog

This method is equivalent to T-SQL command : DBCC CHECKCATALOG

 

4.       CheckTables

This method is equivalent to T-SQL command : DBCC CHECKDB

 

5.       CheckTablesDataOnly

This method is equivalent to T-SQL command : DBCC CHECKDB (‘databasename’, NOINDEX)

 

Example of SMO integrity check functions is shown below:

 

Server srv = new Server(“(local)”);
Database db = srv.Databases[“AdventureWorks2008”];

StringCollection results = db.CheckCatalog();

Foreach ( string result in results)
{
Console.Writeline (result);
}

 

If there is no issue on database integrity (for example : AdventureWorks2008 database on your local machine), it would give message : “DBCC execution completed. If DBCC printed error messages, contact your system administrator”.

Share this post: | | | |
Published Tuesday, January 26, 2010 4:38 PM by Kasim.Wirama
Filed under:

Comments

# Twitter Trackbacks for Database Integrity Check with SMO - SQL Server knowledge center [netindonesia.net] on Topsy.com

Pingback from  Twitter Trackbacks for                 Database Integrity Check with SMO - SQL Server knowledge center         [netindonesia.net]        on Topsy.com

# beauty:design:life: Ms. JD: Networking on a Budget | Business Beauty Wisdom

Pingback from  beauty:design:life: Ms. JD: Networking on a Budget | Business Beauty Wisdom

Powered by Community Server (Commercial Edition), by Telligent Systems