How to corrupt a db

  • Hi all,

    for testing purposes is there a way to corrupt a db via T-SQL or something else?

    Cheers,

    Frank

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • In SQL 6.5 (and sybase) I recall a "DBCC CORRUPT" command, for training purposes. But I also think the database had to be called "corrupt". I'll investigate further...


    Cheers,
    - Mark

  • ...further to that, the database had to be called "victimdb" but no longer works on SQL2k anyway. You can stop mssqlserver and then play around with a hex editor in the mdf file until you get the sort of corruption you're after? For instance, if you change the first byte it'll go straight into suspect mode upon SQL Server startup with an "invalid header" message, but you may have to experiment a bit to get something a bit more subtle.


    Cheers,
    - Mark

  • Hello Mark,

    quote:


    works on SQL2k anyway. You can stop mssqlserver and then play around with a hex editor in the mdf file until you get the sort of corruption you're after?


    of course changing something in hex will corrupt a db. If not done properly, this will crash every kind of file. But that's nothing what someone would unintentionally do. What I'm after is why, which and how T-SQL Statements can corrupt a db. Where are the pitfalls, how can I prevent, and how can I rescue the db?

    Cheers,

    Frank

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • Here you have a script which corrupts the IAM of a table. Note that after running the script the table in question is longer accessible while the database status remains online.

    
    
    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

    [font="Verdana"]Markus Bohse[/font]

  • Interesting!

    Hope there aren't any unscrupulous DBA's with a company grudge reading this.

    Far away is close at hand in the images of elsewhere.
    Anon.

  • It seems that if you can't trust your DBA's, you'll have a problem...

    quote:


    Interesting!

    Hope there aren't any unscrupulous DBA's with a company grudge reading this.


    maybe something to use on the next compensation discussion?

    Cheers,

    Frank

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • Hello Markus,

    quote:


    Here you have a script which corrupts the IAM of a table. Note that after running the script the table in question is longer accessible while the database status remains online.


    thanks, I will try it in the next days!

    ...and surely come up with follow-up questions

    Cheers,

    Frank

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • If you want you can have mine!

  • I found a way to corrupt a DB.

    It works on 7 and 2000.

    Give it to a user / client.

    Cheers,

    Crispin

    Cheers,CrispinI can't die, there are too many people who still have to meet me!It's not a bug, SQL just misunderstood me!

  • Hello kevinbrowne,

    quote:


    If you want you can have mine!


    no chance, just the way how you did it.

    Did you allow any user access, as Crispin mentioned???

    Cheers,

    Frank

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • "For testing purposes, is there a way to corrupt a db via an .ASP page over http?"

    Edited by - spongemagnet on 06/11/2003 3:03:12 PM


    -Ken

  • Hello spongemagnet,

    quote:


    "For testing purposes, is there a way to corrupt a db via an .ASP page over http?"


    don't get me wrong, but I hope there isn't an (at least easy) answer to your question!

    Cheers,

    Frank

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • This didn't work for me.... any suggestions?

  • Kill a long running transaction and while it's rolling back out pull the plug on the server. That's what one of my former clients did. (they didn't have a viable backup either) Big name outfit too.

    John Zacharkan


    John Zacharkan

Viewing 15 posts - 1 through 15 (of 19 total)

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