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 keysoporderreturnid
)soporderreturnline
[order line table] -- stores item data order (has primary keysoporderreurnlineid
, foreign keysoporderreturnid
)
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
Post a Comment