Register

SQL Server Code to Generate Status Report Of DB Health

Tools and Materials needed by SQL Server Admins worldwide.
Site Admin
Posts: 180
Joined: 27 Feb 2012, 16:26
Location: Egypt , Cairo

SQL Server Code to Generate Status Report Of DB Health

Postby Softex » 09 Feb 2016, 10:54

If you are suspecting your SQL Server Database is acting strange and you fear it is moving into corruption, try running the below script to Generate Detailed report of all User Tables Integrity and data correctness..

In order for this Script to run, the Database has to be in Single user Mode, so the below script makes you Change it to Single mode, run the scan then Change it Back to multi User.

Just Replace YourDBName_Here with the name of the database you want to check.

Cheers.

Code: Select all

 
--Changing it to Single Mode
ALTER DATABASE YourDBName_Here SET SINGLE_USER
GO

--Performing the Full Scan Report
DBCC CHECKDB('YourDBName_Here', REPAIR_REBUILD)
GO

--Changing it Back to Multi users Mode
ALTER database YourDBName_Here SET MULTI_USER

GO

Softex Software House
Tech. Team
http://www.softexsw.com

Return to Microsoft SQL Server Database Systems

Who is online

Users browsing this forum: No registered users and 1 guest

Fatal: ./cache/ is NOT writable.