Make DB Suspect

  • For testing purposes, how do I make a database 'suspect'? Thank you!

  • The easiest way is to make the disk "unavailble". I'd do this by denying the MSSQLServer login account read permission to the disk which stores the data file.

    Hope that helps

     

    http://www.sqlporn.co.uk 

  • I denied read access, but the db is still functional. If I take the db offline, then I have problem bring it only due to the data file not accessible. Whatelse do I need to do to make the db 'suspect'?

  • You can use the following script

    use master

    go

    sp_configure 'allow updates', 1

    reconfigure with override

    go

    update sysdatabases

    set status = 256

    where name = 'DBname'

    go

    sp_configure 'allow updates', 0

    reconfigure

    go

    checkpoint

    go

    shutdown

    go

    To bring the db out of suspect mode:

    update sysdatabases

    set status = status - 256

    where name = 'DBName'

    and status & 256 = 256

  • Thank you, Katya. Your script worked!

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply