debugMinor
voluntarily produce an error with DBCC CheckDb
Viewed 0 times
errorproducewithdbcccheckdbvoluntarily
Problem
Would anyone know how I can make DBCC CheckDB produce an error?
I'm testing a script and need DBCC Checkdb in the simplest mode to return an error, also while trying to repair and when trying to go into single user mode...
The simple dbcc checkdb command thant I'm using is part of a batch file and is as follows:
If no errors are found the script ends. If errors are found, the script tries to fix them with the REPAIR_REBUILD option and if that fails the script tries to fix them with REPAIR_ALLOW_DATA_LOSS option. Obviously, before trying to Repair the script attempts to put the DB in Single user mode (which is also error trapped)
So All I'm looking for is a way to cause DBCC CheckDB to return an error.
I'm testing a script and need DBCC Checkdb in the simplest mode to return an error, also while trying to repair and when trying to go into single user mode...
The simple dbcc checkdb command thant I'm using is part of a batch file and is as follows:
OSQL -S MYPC -E -d MyDB -l 10 -Q "DBCC CHECKDB(AG_DB_STORESQL)" -b -o c:\MyFolder\MSSQL_DB_CHECK.LogIf no errors are found the script ends. If errors are found, the script tries to fix them with the REPAIR_REBUILD option and if that fails the script tries to fix them with REPAIR_ALLOW_DATA_LOSS option. Obviously, before trying to Repair the script attempts to put the DB in Single user mode (which is also error trapped)
So All I'm looking for is a way to cause DBCC CheckDB to return an error.
Solution
Handy corruption demo script has been created by Paul Randal. These are really good and would help you a lot. Please browse below links
-
Corruption demo databases and scripts
-
Using DAC connection to fix corrupt system tables
-
Various SQL Server Database corruption scenarios
-
Corruption demo databases and scripts
-
Using DAC connection to fix corrupt system tables
-
Various SQL Server Database corruption scenarios
Context
StackExchange Database Administrators Q#135195, answer score: 5
Revisions (0)
No revisions yet.