On Insert Trigger - Data Capture of Insert

What is the best way to capture all information that is inserted into a table using on On Insert trigger?
IT GuyDir of ITAsked:
Who is Participating?
 
Aneesh RetnakaranDatabase AdministratorCommented:
something like this


CREATE TRIGGER dbo.SampleTable_InsertTrigger
ON dbo.SampleTable
FOR INSERT
AS
BEGIN
   INSERT INTO dbo.TargetTable (Column1, column2, column3 )    
   SELECT Col1, col2, col3
   FROM inserted;
END;
0
 
IT GuyDir of ITAuthor Commented:
So I can SELECT from INSERTED to capture the data that was just inserted?
0
 
Aneesh RetnakaranDatabase AdministratorCommented:
that's correct.
0
 
IT GuyDir of ITAuthor Commented:
Thank you.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.