What are the commands to reindex, rebuild, or check the SQL database for Errors?

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.

-- 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
  • Entered : 04/2011

Corruption, re-index, index, rebuild, repair, dbcc, dbcc checkdb

You could leave a comment if you were logged in.