Sql-server – How to corrupt a table in SQL Server

corruptionsql-server-2005

I have to write a program that detects corrupted tables and tries to repair them. For this I need to corrupt tables regularly.

Is there anyway to corrupt tables manually?

Best Answer

Paul Randal has several Sample corrupt databases to play with:

  • DemoDataPurity - 192-MB SQL Server 2005 database with a single 2570 (data purity) error

  • DemoFatalCorruption1 - 1-MB SQL Server 2005 database with a corrupt system table (that allows CHECKDB to complete)

  • DemoFatalCorruption2 - 1-MB SQL Server 2005 database with a corrupt system table (that terminates CHECKDB)

  • DemoNCIndex - 192-MB SQL Server 2005 database with a bunch of nonclustered index corruptions

  • DemoRestoreOrRepair - 1-MB SQL Server 2005 database with a page checksum failure (in fact a zero'd out page)

  • DemoCorruptMetadata - 1-MB SQL Server 2000 database with corrupt syscolumns table

Also, How to create a corrupt database using BULK INSERT/ UPDATE and BCP - SQL Server as a HEX editor.