Recover Corrupted SQL Server Tables
In cases, you might see the tables get corrupted in SQL Server hence the DinePlan.
Here are the steps to identify and work on.
In DinePlan Log, if anything is noticed as below
STEP 1: Check the DB using the Following Statements
The following statements should be executed to get the status of the issue on the DinePlan DB
DBCC CHECKDB
If you see above, you can see the Issues are with the MenuItemPrices table.
You can confirm again as below
STEP 2: Clear the Corrupt Table as below
The following statements put the Database in the Single User Mode. You should change [DB] to DinePlan DB
ALTER DATABASE [DB] SET SINGLE_USER WITH NO_WAIT
or it can be set via SQL Server Management Studio as below
During the Single User Mode, if you get the error that it is being used by other Service. Please restart the SQL Server and issue it again.
The following statements put the Database in the Single User Mode. You should change [DB_Table] to DinePlan Table
DBCC CHECKTABLE ('DB_TABLE', repair_allow_data_loss)
Execute the above statement until you get the following screens as below
If we get many tables in the DB (DBCC CHECKDB), you should execute the above statement for each table
DBCC CHECKTABLE ('DB_TABLE', repair_allow_data_loss)
Table Names from the DBCC.
STEP 3: MULTI-USER MODE
Once the above database corrupted tables are correct, the following statements put back the DB to Multi-user Mode
ALTER DATABASE [DB] SET MULTI_USER WITH NO_WAIT