XPost: microsoft.public.sqlserver.programming   
   From: genew@ocis.net   
      
   On Sat, 09 Apr 2011 11:22:07 +0200, Erland Sommarskog   
    wrote:   
      
   >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.   
      
    1) Part of adding a column would be considering whether it needs   
   this adjusting and so to add its handling to the trigger.   
      
    2) I think that maintainability was covered by the code I borrowed   
   from. My derivative has   
    select * into #Inserted from Inserted   
   at the beginning and then at the end, writes with   
    insert into Accounts select * from #Inserted   
      
   >What you really want is a BEFORE trigger where you can modify inserted.   
   >But unfortunately SQL Server does not have BEFORE triggers.   
      
   Sincerely,   
      
   Gene Wirchenko   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|