Creating trigger on stored procedure

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Basanth
    New Member
    • Jul 2013
    • 7

    Creating trigger on stored procedure

    i know, it sounds odd but i want to create a trigger on a sp is it possible, if not why?
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    What is the purpose of this? What are you trying to do? I can't really think of a scenario that would require this because stored procedures are explicitly called, therefore making triggers on them unnecessary.

    Comment

    • Basanth
      New Member
      • Jul 2013
      • 7

      #3
      i am hoping track if anybody modifying the SPs other than me and i want to know is it possible in any way... may not be by triggers.

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        It sounds more like you want logging and or version control. If it's logging you want, the database administrators will have access to the logs, and if not, they can turn logging on. As for version control, you just need to treat stored procedures like you would any other coding project.

        If the reason for this is that your stored procedures are being changed by someone that shouldn't be changing them, then that's a security issue. The database administrators need to set up the permissions correctly so that only you are allowed to modify the stored procedure.

        Comment

        • ck9663
          Recognized Expert Specialist
          • Jun 2007
          • 2878

          #5
          You can try to create a database trigger.

          Good Luck!!!


          ~~ CK

          Comment

          • Basanth
            New Member
            • Jul 2013
            • 7

            #6
            Finally!!!
            Code:
            CREATE TRIGGER DDLTrigger_Sample
            ON DATABASE
            FOR ALTER_PROCEDURE, DROP_PROCEDURE
            AS
            BEGIN
            //Your logic
            END
            Last edited by Rabbit; Jul 31 '13, 05:25 PM. Reason: Please use code tags when posting code or formatted data.

            Comment

            Working...