views:

56

answers:

1

How can I manually introduce an integrity error into my database for the purpose of testing, without totally corrupting the database so that I can still run my program.

Updating with a more specific question...

The actual feature that I am testing runs DBCC CHECKDB and what I am testing is that it reports a failure to the user.

+1  A: 

There are some sample corrupt databases here http://www.sqlskills.com/BLOGS/PAUL/post/Sample-corrupt-databases-to-play-with.aspx

Or to corrupt your own see this post http://sqlblogcasts.com/blogs/tonyrogerson/archive/2007/03/10/how-to-create-a-corrupt-database-using-bulk-insert-update-and-bcp-sql-server-as-a-hex-editor.aspx. The first one on that link looks suitable as corrupting a not frequently used Non Clustered index should allow your program to run and also be recoverable from by rebuilding the index (but obviously take appropriate backup steps first!).

Another good link which might be closest to your needs. http://sqlblogcasts.com/blogs/christian/archive/2007/10/07/how-to-corrupt-a-page-in-a-specific-index-and-then-fix-it.aspx

Martin Smith