Re: FORCE DB Corruption

From: Mark Allison (marka_at_no.tinned.meat.mvps.org)
Date: 11/19/04


Date: Fri, 19 Nov 2004 16:30:15 +0000

This script from Sharon Dooley should do the trick - be careful with it
though!! I haven't tried it on SQL 2000, but it should work.

/* this script works on a database that is a copy of pubs. I created
this database easily with DTS This only works on SQL Server 7 databases
*/

/* NOTE: This script will truly corrupt a database. It should not be run
on ANY real database. It is only for simulating corruption for training
purposes.
*/
sp_configure allow, 1
go
reconfigure with override
go
update sysindexes set FirstIAM = 1234
where id = OBJECT_ID('roysched')
go
sp_configure allow, 0
go
reconfigure with override
go

--
Mark Allison, SQL Server MVP
http://www.markallison.co.uk
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602m.html
michelle wrote:
> Hi,
> 
> I need to test a script to ensure that it behaves appropriately after
> running DBCC CHECKDB and finding 'errors'. I have an if statement that runs
> if @@error = 0 but I want to make sure that it works as intended should DBCC
> CHECKDB FIND errors. How can I force a database to become corrupt to a point
> that DBCC CHECKDB will report errors?
> 
> Thanks,
> 
> Michelle
> 
> 


Relevant Pages

  • Re: Cannot Open SQL Server Table in Access.ADP File.
    ... I dont think that SQL Server will take 'veiw dependencies' into effect; ... Generate Script Wizard did not work on my original database, ... After fixing some of my tables and a few stored procedures and views, ...
    (microsoft.public.access.adp.sqlserver)
  • Re: Enterprise Manager Newbie Question
    ... a SQL backup is not a simple copy of the database files. ... Is it possible to write a script that one could run from a workstation and ...
    (microsoft.public.sqlserver.tools)
  • Re: SQL Security
    ... except I'm having problems making it work in a script. ... ;Set properties of DB objects and open connection to database ... > from Books Online (within the SQL Server program group): ... > communicate with SQL Server. ...
    (microsoft.public.sqlserver.server)
  • Re: Vista hosting XPe tools/db
    ... Are you running this script on the machine that actually has the SQL server ... machine hosting the database. ... i don't know if you can install a second instance of SQL ...
    (microsoft.public.windowsxp.embedded)
  • Re: Problem SQL 6.5
    ... In SQL 6.5 the error 605 it is very hard to solve, Execute DBCC CHECKDB on ... the database and identify the table got corrupted. ... Script out the indexes of that table. ... rename the original table to tablename_old ...
    (microsoft.public.sqlserver.server)