Einfügen in eine Tabelle mit einer Unterauswahl?

Ich habe diese Audit-Tabelle:

create table audit( id int IDENTITY(1, 1) NOT NULL, item_id int NOT NULL, history text NOT NULL, ) 

Und ich habe diesen Auslöser:

 create trigger tr_mytable_audit ON mytable after insert, update, delete as select * from inserted as i full join deleted as d on i.id = d.id for xml path('row'), root('rows') 

Wie kann ich datasätze in die Audit-Tabelle item_id wobei item_id die id Spalte aus entweder inserted oder deleted und die history Spalte die XML-file für diesen datasatz enthalten sollte.

Also meinst du das

 create trigger tr_mytable_audit ON mytable after insert, update, delete as INSERT INTO audit(item_id, history) SELECT i1.id, ( select * from inserted as i full join deleted as d on i.id = d.id where i.id=i1.id for xml path('row'), root('rows') ) from inserted i1 UNION SELECT i1.id, ( select * from inserted as i full join deleted as d on i.id = d.id where d.id=d1.id for xml path('row'), root('rows') ) from deleted d1