Update field in new record based on value of another field in thesame record - 10-23-2010 , 11:44 AM
I want to update a field when a new timecard record comes in based
upon the value in another field on the same record and the value of
another field in a different table.
If I were writing a SQL statement for after the fact it would be:
update timecard set tudef1='JP0' where tudef5='JP' and tmatter in
(select mmatter from matter where mloc<>'30')
but I sure would like to do it with a trigger when the original input
Thanks in advance.
Re: Update field in new record based on value of another field in the same record - 10-23-2010 , 02:01 PM
Richard (richard.mogy (AT) gmail (DOT) com) writes:
SET tudefl = 'JPO'
FROM timecard t
WHERE EXISTS (SELECT *
FROM inserted i
WHERE t.key = i.key
AND i.tudef5 = 'JP'
AND i.tmatter in (select m.mmatter
Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) 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