Trigger on a system table

  • Folks, My question is more on MS policies than technical. I am planning on writing a trigger on system table sysconfigures, to notify the DBA's if there is any change in sys configure options. Does it become an issue with MS Supporting the system in case if you need any help from MS down the line ?

    Appreciate your response

    Thanks

    Shas3

  • Yes the db will become unsupported. Also triggers on system tables don't always work because some changes are handled entirely by the server (without actually using update statements >> making the trugger not fire).

  • Thanks for the reply Rgr'us. Brain or Andy can you please comment on  this if you know any details or links to MS Support on SQL Server 2000.

    Thanks

     

    Shas3

  • I'd check in the server's EULA for system tables. You'll most likely find that info there.

  • Triggers are not allowed on SQL Server 2000 system tables and any attempt to create a trigger will cause the the following error message:

    Server: Msg 229, Level 14, State 5, Procedure sysobjects_tia, Line 4

    CREATE TRIGGER permission denied on object 'sysobjects', database 'tempdb', owner 'dbo'.

    To reproduce, try running:

    create trigger sysobjects_tia

    on dbo.sysobjects for insert

    as

    select * from inserted

    go

    SQL = Scarcely Qualifies as a Language

  • There are certain systable that you can not create triggers like sysobjects, however you can create a trigger on sysconfigures, make sure enable the option "allow changes to system tables" option.

     

    Shas3

  • As I said, it's possible but it's a worst practice, at best. Do at your own risks.

  • Point take Rgr. I am looking for other's opinion as well. Thanks for your post again.

    Shas3

  • How much more opinions do you need?

    Anyway, if you also like to overclock your servers, check this out: http://www.sqlservercentral.com/columnists/rmarda/letsblockthedba.asp

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

  • Shas3,

    A long time ago, in a galaxy not so far away, Robert Marda experimented with triggers on system tables and posted the results in these very forums. His results showed that while you can get triggers on some of the system tables, you could not guarantee they would fire, just as what has been posted here by Remi. Also, as has been pointed out, if you do put a trigger on, you do have a situation where you've brought your database to an unsupported state.

    If you're trying to check the sysconfigures, why not do this? Dump the results of sysconfigures to a table in a work database. Every five to ten minutes run a SQL Server agent job that compares the config and status columns with what is currently in sysconfigures with what you have stored. If there's a difference, fire off your alert. That'll accomplish the same result as far as notifying about changes. If you need to know "who done it," you can have a sql trace logging statement execution against the master database, could you not?

    K. Brian Kelley
    @kbriankelley

  • Brain thanks for your reply. In fact that's exactly what we have in place right now, what we are looking though is to replace it with a trigger with out violating MS Support policy. We decided to leave it as it is right now.

    Thank you all for your posts.

     

    Shas3

Viewing 11 posts - 1 through 10 (of 10 total)

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