Create an Integrity error for an SQL Server Database for the purpose of Testing
How can I manually introduce an integrity error into my开发者_如何学Go 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.
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
精彩评论