List members for "inserted" and "deleted" pseudo tables in trigger body
![](https://secure.gravatar.com/avatar/1c1426063e634d5c9a6867fee6997755?size=40&default=https%3A%2F%2Fassets.uvcdn.com%2Fpkg%2Fadmin%2Ficons%2Fuser_70-6bcf9e08938533adb9bac95c3e487cb2a6d4a32f890ca6fdc82e3072e0ea0368.png)
Version 3.0 is on the site
-
invm commented
Had in mind pseudo-tables "inserted" and "deleted". They are used in triggers and DML-statements with output clause. For example:
1. trigger
/*Simple logging trigger*/
create trigger dbo.trWriteJournal
on dbo.TestTable
for insert, update, delete
as
begin
insert into dbo.TestTable_Journal
(row_id, Value_Old, Value_New)
select
coalesce(i.row_id, d.row_id, d.Value, i.Value)
from
inserted i full join
deleted d on d.row_id = i.row_id
end2. DML-statement with output clause
update dbo.TestTable
set
Value = Value + 1
output
deleted.Value, inserted.Value into dbo.AnotherTestTable (Value1, Value2)
where
row_id between 1 and 100