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,573 of 19,505   
   Gene Wirchenko to esquel@sommarskog.se   
   Re: Trigger help   
   02 Apr 12 20:52:52   
   
   From: genew@ocis.net   
      
   On Mon, 02 Apr 2012 23:45:21 +0200, Erland Sommarskog   
    wrote:   
      
   >Johnnyb (john.lutheran@gmail.com) writes:   
   >> I need to create a trigger that will fire when particular text shows up   
   >> in a particular column. Then I need to copy that row to another table.   
   >> Not sure how to do this. Any help would be greatly appreciated.   
   >   
   >CREATE TRIGGER tri ON tbl AFTER INSERT, UPDATE AS   
   >IF EXISTS (SELECT *   
   >           FROM  inserted   
   >           WHERE  col LIKE '%particular text%')   
   >BEGIN   
   >   -- Do something here.   
   >END   
   >   
   >   
   >inserted holds the inserted rows, or in case of an UDPATE statement, the   
   >updated rows after the UPDATE.   
   >   
   >Don't forget to consider what should happen if the text appears both   
   >before and after the update.   
      
        Why would this be relevant since the trigger is for after the   
   insertion?  Assuming the above is correct, I think that I am missing a   
   nuance.   
      
   Sincerely,   
      
   Gene Wirchenko   
      
   --- 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