home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.databases.ms-sqlserver      Notorious Rube Goldberg contraption      19,505 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 18,222 of 19,505   
   Erland Sommarskog to Gene Wirchenko   
   Re: SSE 2008: Trigger: Modifying Data to   
   09 Apr 11 11:22:07   
   
   XPost: microsoft.public.sqlserver.programming   
   From: esquel@sommarskog.se   
      
   Gene Wirchenko (genew@ocis.net) writes:   
   >      Thank you. I found an example of INSTEAD OF myself shortly after   
   > posting.  Half the battle of learning SQL Server is knowing exactly   
   > what to ask for, and sometimes, it is the tougher half!   
      
   I like to add that many developers would prefer to do this with an AFTER   
   trigger. This means a higher overhead, because the bad data is first   
   written to the table, and then you need to update the target table.   
   On the other hand, INSTEAD OF triggers gives you a maintainability   
   problem. Since you need to redo the original statement, you need to   
   update the trigger every time you add a column to the table. If you   
   forget you may get some headache sorting out what is going on.   
      
   What you really want is a BEFORE trigger where you can modify inserted.   
   But unfortunately SQL Server does not have BEFORE triggers.   
      
      
   --   
   Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se   
      
   Links for SQL Server Books Online:   
   SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx   
   SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca