Show pageOld revisionsBacklinksBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. CKG Edit ===== Question ===== What are the commands to reindex, rebuild, or check the SQL database for Errors? ===== Answer ===== SQL Server has a built-in set of functions that allow you to perform tasks to check and repair the overall integrity of the SQL database. There are many different functions available, refer to the reference links listed below for additional information. ==== DBCC CheckDB ==== <code sql> -- Only run this command after the following has been completed. -- Shutdown Control, SSLIP, Restart SQL, Backup Database. EXEC sp_resetstatus StoreData; GO ALTER DATABASE StoreData SET EMERGENCY GO DBCC checkdb(StoreData) GO ALTER DATABASE StoreData SET SINGLE_USER WITH ROLLBACK IMMEDIATE GO DBCC CheckDB (StoreData, REPAIR_ALLOW_DATA_LOSS) GO ALTER DATABASE StoreData SET MULTI_USER </code> ===== Reference Links ===== * [[http://en.wikipedia.org/wiki/Database_Console_Commands_%28Transact-SQL%29|Database Console Commands - Wikipedia]] * [[http://msdn.microsoft.com/en-us/library/ms176064.aspx|DBCC CheckDB (Transact-SQL) - MSDN]] ===== Version Information ===== * Entered : 04/2011 ===== Keywords ===== Corruption, re-index, index, rebuild, repair, dbcc, dbcc checkdb