SQL Server Code to Generate Status Report Of DB Health
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.
--Changing it to Single Mode
ALTER DATABASE YourDBName_Here SET SINGLE_USER
--Performing the Full Scan Report
DBCC CHECKDB('YourDBName_Here', REPAIR_REBUILD)
--Changing it Back to Multi users Mode
ALTER database YourDBName_Here SET MULTI_USER