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,
MichelleThis 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
>|||Thanks! I thought that I remembered something from PASS one year but was
having trouble wading through the numerous results regarding db corruption
to find what I was looking for.
This DOES work on SQL2000 and DID corrupt a copy of the pubs database.
Thanks!
"Mark Allison" <marka@.no.tinned.meat.mvps.org> wrote in message
news:OZC$NUlzEHA.3488@.TK2MSFTNGP10.phx.gbl...
> 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
> >
> >
No comments:
Post a Comment