March 9, 2004 at 1:30 pm
I have a table called "PROD" that contains summarized data from other "DETAIL" tables.
Whenever a "Detail" table is updated, an entry is inserted into an audit table.
The summary table contains the fields:
PROD
--------
USERID
EVENTID
EVENT_DATE
AMOUNT
TEAMID
The audit table contains:
AUDIT
--------
USERID
EVENTID
ORIG_EVENT_DATE
CHANGE_DATE
The only way to relate the PROD and AUDIT tables is where PROD.USERID = AUDIT.USERID AND PROD.EVENTID = AUDIT.EVENTID AND PROD.EVENT_DATE = AUDIT.ORIG_EVENT_DATE
Is there a way to do this with straight SQL, or do I need to use Cursors. If the latter, please provide an example. I've never used cursors.
March 9, 2004 at 1:43 pm
A way to do exactly what?
--Jonathan
March 9, 2004 at 7:28 pm
To delete records from PROD for matching records in AUDIT, given the constraints I listed in the original post.
March 9, 2004 at 7:40 pm
DELETE p
FROM Prod p JOIN Audit a ON p.UserID = a.UserID AND p.EventID = a.EventID AND p.Event_Date = a.Orig_Event_Date
--Jonathan
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply