How to corrupt SQL database?

I need to test the behaviour of the application when the database is corrupted. So can somebody please tell what are the different ways to corrupt the database.

more ▼

asked Oct 30, 2009 at 12:46 PM in Default

Chilika Pujari gravatar image

Chilika Pujari
76 3 3 4

Am I the only one that finds it amusing that the desired behavior is a corrupt database and the tag is "best-practice"?
Oct 30, 2009 at 02:09 PM Tom Staab
(comments are locked)
10|1200 characters needed characters left

5 answers: sort oldest

Paul Randal is the king of corruption. That's actually a complement, even though it sounded lousy.

His blog articles have demoed how to "corrupt" SQL Server DB files on a number of occasions...here's one that I quickly googled:


more ▼

answered Oct 30, 2009 at 01:11 PM

Aaron Alton gravatar image

Aaron Alton
575 2

"Paul Randal is the king of corruption" - love it!
May 04, 2012 at 08:51 PM Kev Riley ♦♦
And now we all know how to corrupt da database. Paul published a blog post yesterday: http://www.sqlskills.com/blogs/paul/dbcc-writepage/
Feb 06, 2013 at 09:25 AM DirkHondong
(comments are locked)
10|1200 characters needed characters left

Well, the simplest way is probably to detach a DB, then write a small application which just writes garbage into a few of the files.

If you're feeling a bit more dangerous, you could always start a big write and unplug the drive data cable half way through (don't do this with a PATA drive though).

more ▼

answered Oct 30, 2009 at 12:57 PM

Matt Whitfield gravatar image

Matt Whitfield ♦♦
29.5k 61 65 87

(comments are locked)
10|1200 characters needed characters left

Also, there is a posting at: http://sqlblog.com/blogs/linchi_shea/archive/2007/08/29/how-to-corrupt-a-sql-server-2005-database.aspx . I am not sure it would be in line with with what you would like to accomplish.

more ▼

answered Oct 30, 2009 at 01:06 PM

Mansour Shoari gravatar image

Mansour Shoari
435 14 14 16

(comments are locked)
10|1200 characters needed characters left

I was reminded of this question when I saw today's article on SQLServerCentral. [How to Create a Corrupt SQL Server Database][1] by Perry Whittle.

[1]: http://www.sqlservercentral.com/articles/CheckDB/88963/
more ▼

answered May 04, 2012 at 05:14 PM

TimothyAWiseman gravatar image

15.6k 20 23 32

(comments are locked)
10|1200 characters needed characters left
I have a corrupted MDF file and backup is not available. I have tried so many software but they didn’t works well. Anybody please suggest me what should I do and if there is any other way to recover my corrupted database.
more ▼

answered Feb 06, 2013 at 09:08 AM

simondesouza gravatar image


Dude, ask this as a separate question, not as an answer to an ages-old question on how to create a corrupted database.

Going on what little you've said here, though, you've got problems.
Feb 06, 2013 at 11:39 AM ThomasRushton ♦
(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

New code box

There's a new way to format code on the site - the red speech bubble logo will automatically format T-SQL for you. The original code box is still there for XML, etc. More details here.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.



asked: Oct 30, 2009 at 12:46 PM

Seen: 7197 times

Last Updated: Aug 04 at 12:08 PM