Advertisement

03.24.2008 at 09:22PM PDT, ID: 23266089
[x]
Attachment Details

T-SQL audit trigger for insert, update inserting 2 rows

Asked by dneill8 in SQL Server 2005

Tags: T-SQL MSSQL

The trigger listed below is inserting two rows into the audit table requests_audit.  I was under the impression this syntax would insert the specified values for _either_ and insert or and update action.  What am I doing wrong? TIAStart Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
CREATE TRIGGER Requests_Audit_Trigger on dbo.Requests
for INSERT, UPDATE
as
INSERT INTO Requests_Audit
(requestid,
SirvaRepName,
LeadID,
...
originzipinvalid,
destzipinvalid,
CancelReasonID)
SELECT TOP 1 i.RequestID,
i.SirvaRepName,
i.LeadID,
...
i.originzipinvalid,
i.destzipinvalid,
i.CancelReasonID
FROM inserted i;
 
 
[+][-]03.24.2008 at 09:27PM PDT, ID: 21199489

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.24.2008 at 09:49PM PDT, ID: 21199550

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.25.2008 at 03:59AM PDT, ID: 21200773

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]03.25.2008 at 09:01PM PDT, ID: 21208803

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.26.2008 at 05:24AM PDT, ID: 21210814

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: SQL Server 2005
Tags: T-SQL MSSQL
Sign Up Now!
Solution Provided By: chapmandew
Participating Experts: 1
Solution Grade: A
 
 
[+][-]05.13.2008 at 08:04PM PDT, ID: 21560941

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628