Adding a where clause to a SQL Server trigger -


i'm looking add where clause trigger shown below , looking bit of advice if possible. trigger works on basis of particular items being added order , not specific ones (ideally prefix).

create trigger italianemail on soporderreturn insert, update     declare @soporderreturnid int;      update soporderreturn     set analysiscode19 = 'mario@aol.com'     soporderreturn     inner join inserted on soporderreturn.soporderreturnid = i.soporderreturnid) go 

the layout of tables in sql server following:

  • soporderreturn [header table] -- holds order information (has primary key soporderreturnid)

  • soporderreturnline [order line table] -- stores item data order (has primary key soporderreurnlineid , foreign key soporderreturnid)

i need where clause pick stockitem on soporderreturnline table if like 'xxx_%'

i hope have explained enough of structure of tables idea of achieve?

any offered gratefully appreciated , thank time.

try following. notice alias on

create trigger italianemail on soporderreturn insert, update     declare @soporderreturnid int;      update oret     set analysiscode19 = 'mario@aol.com'     soporderreturn oret     inner join inserted on (oret.soporderreturnid = i.soporderreturnid)     inner join soporderreturnline oretline on (oretline.soporderreturnid = i.soporderreturnid)     oretline.stockitem 'xxx%'  go 

Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -