May 3, 2012 at 9:35 pm
Comments posted to this topic are about the item How to Create a Corrupt SQL Server Database
-----------------------------------------------------------------------------------------------------------
"Ya can't make an omelette without breaking just a few eggs" 😉
May 4, 2012 at 1:48 am
nice - not sure it's got too many practical implementations other than showing a junior how to run and correct checkdb, but it's still nice to have in your arsenal
MVDBA
May 4, 2012 at 3:07 am
Hi Michael, as the article mentions it's ideal for testing DBCC scripts against and also for practising dealing with a corrupt database.
It also gives you an idea of what the data pages actually look like to
-----------------------------------------------------------------------------------------------------------
"Ya can't make an omelette without breaking just a few eggs" 😉
May 4, 2012 at 3:21 am
Thanks - this would be a nice test for a practical interview if hiring for a DBA. Corrupt a bunch of things in advance and show the interviewee the DBCC CHECKDB results and see how many of them he/she can fix in 15 minutes.
Ben
^ Thats me!
----------------------------------------
01010111011010000110000101110100 01100001 0110001101101111011011010111000001101100011001010111010001100101 01110100011010010110110101100101 011101110110000101110011011101000110010101110010
----------------------------------------
May 4, 2012 at 4:00 am
Really enjoyed the article. Thanks. Great demo for my advanced training labs. Have done this in Oracle several times and is interesting to see how SQL server pages map out by comparison. There are many more control fields in Oracle but the design drivers are exactly the same - how do you delploy object data into linear records in an ordinary file - and then how do you find that data. /BW/ PS. screwed up the feedback - sorry. Meant to be 5 stars, Idiot!
May 4, 2012 at 5:26 am
this is really good stuff. thank you.
btw, this is also good for using to test a database mirror. i had to create a broken db once for testing failover. 😛
May 4, 2012 at 6:40 am
dioscoredes (5/4/2012)
Really enjoyed the article. Thanks. Great demo for my advanced training labs. Have done this in Oracle several times and is interesting to see how SQL server pages map out by comparison. There are many more control fields in Oracle but the design drivers are exactly the same - how do you delploy object data into linear records in an ordinary file - and then how do you find that data. /BW/
Thank you for your feedback.
For more info on in row and off row data in SQL Server see the following MS link
dioscoredes (5/4/2012)
PS. screwed up the feedback - sorry. Meant to be 5 stars, Idiot!
LOL grr never trust an Oracle DBA 🙂
-----------------------------------------------------------------------------------------------------------
"Ya can't make an omelette without breaking just a few eggs" 😉
May 4, 2012 at 10:22 am
michael vessey (5/4/2012)
nice - not sure it's got too many practical implementations other than showing a junior how to run and correct checkdb, but it's still nice to have in your arsenal
Maybe but it could be taken beyond just knowing to run DBCC commands. Back around 1999-2000 I had an issue similar to this but it would cause a query to fail and disconnect the session and of course, checkdb did fix it. The real challenge came when I was tasked with a root cause analysis. I thought by fixing it I was free and could move on. Not so, my boss wanted to know the how and why it happened. So perhaps this script and information are useful in that they could be helpful in developing investigative techniques.
Cheers
May 6, 2012 at 5:38 am
Nice and simple. Thanks.
Usually beginners comes on forum to find solution from experts and sometimes things are not meant for experts as such. However experts correction and appreciation makes them feel part of community.
Good work.
Cheers.
May 6, 2012 at 7:22 pm
I loved this article. Very interesting to some of us who are learning the SQL Server internals and need to simulate disaster recovery.
Best regards,
Andre Guerreiro Neto
Database Analyst
http://www.softplan.com.br
MCITPx1/MCTSx2/MCSE/MCSA
May 7, 2012 at 1:09 am
Thanks for your feedback, please don't forget to rate the article to.
-----------------------------------------------------------------------------------------------------------
"Ya can't make an omelette without breaking just a few eggs" 😉
June 27, 2012 at 6:37 am
Five stars for me as I find this type of article almost a "reverse engineering" concept, sometimes this can help with the understanding.
Good stuff.
qh
June 27, 2012 at 8:21 am
hi thanks for your comments, hope you found it useful
Regards Pez
-----------------------------------------------------------------------------------------------------------
"Ya can't make an omelette without breaking just a few eggs" 😉
August 22, 2012 at 6:31 am
mY database will be corrupted [font="Arial"][/font].so how to recovery the corrupt database??????( i have little bit confusing.because of iam using below script reocvery the database :
DBCC CHECKDB ('Corrupt2K8') WITH NO_INFOMSGS, ALL_ERRORMSGS
exec sp_resetstatus 'Corrupt2K8'
alter database Corrupt2K8 set emergency
dbcc checkdb('Corrupt2K8')
alter database Corrupt2K8 set single_user with rollback immediate
dbcc checkdb('Corrupt2K8', REPAIR_ALLOW_DATA_LOSS)
alter database Corrupt2K8 set multi_user ))
NOTE: some points for consideration:
Then restore My database from a backup - but make sure to run DBCC CHECKDB on that very backup to ensure it's not corrupt itself.
DBCC CHECKDB with REPAIR_ALLOW_DATA_LOSS is the very last resort . Before that, you should restore a valid backup. Once you do use REPAIR_ALLOW_DATA_LOSS, don't expect your database to magically come back to life again - most likely, irreparable damage has occurred - especially in this case since it complains about system table corruption.
Thank you in advance
SQL server DBA
August 8, 2014 at 1:08 am
Hi, It worked well but as I execute command to bring the database online after modifying the .mdf file. SQL Server throws an error:
Msg 926, Level 14, State 1, Line 1
Database 'Corrupt2K8' cannot be opened. It has been marked SUSPECT by recovery. See the SQL Server errorlog for more information.
Msg 5069, Level 16, State 1, Line 1
ALTER DATABASE statement failed.
Msg 5125, Level 24, State 2, Line 1
File 'E:\SQL DATA\Corrupt2K8.mdf' appears to have been truncated by the operating system. Expected size is 524288 KB but actual size is 524280 KB.
Msg 3414, Level 21, State 1, Line 1
An error occurred during recovery, preventing the database 'Corrupt2K8' (database ID 10) from restarting. Diagnose the recovery errors and fix them, or restore from a known good backup. If errors are not corrected or expected, contact Technical Support.
Viewing 15 posts - 1 through 15 (of 25 total)
You must be logged in to reply to this topic. Login to reply