Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
thanksfor help
Posting Yak Master
106 Posts |
Posted - 2007-03-30 : 14:24:40
|
Hi,I have 2 tablesTable Aid, lastmodifieddate, colA, Colb,ColC,...............Table Bid, lastmodifieddate, colA, Colb,ColC,...............Table Aid lastmodifieddate1 3/18/20072 3/2/20073 3/15/20074 3/20/2007Table Bid lastmodifieddate1 3/2/20072 3/2/20071 3/10/20073 3/10/20073 3/15/20071 3/18/20074 3/20/2007By this for very change in Table A is captured in table B. Please let me way to insert the records in Table BHere is my logicselect a.* from TableA ainner join TableB B on a.[id] = B.[id]where a.LastModifiedDate > (select max(B.LastModifiedDate) from TableB c1 where c1.[id] = a.[id])I am getting error for having agg function in where.Thanks in advance. |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-03-30 : 15:11:21
|
Create a TRIGGER for tableA. An UPDATE/INSERT trigger. And even DELETE trigger?CREATE TRIGGER trgTableA_AuditFOR UPDATE, INSERTINSERT TableB (ID, LastModifiedDate)SELECT ID, CURRENT_TIMESTAMP FROM INSERTEDPeter LarssonHelsingborg, Sweden |
 |
|
thanksfor help
Posting Yak Master
106 Posts |
Posted - 2007-03-30 : 16:21:08
|
thanks for quick reply.It is not possible to add trigger to that table because it updated by different application and my process don't have control.Is it possible to write some query and to find the modified records and insert in Table B.thanks in advance. |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-03-30 : 16:27:02
|
You can check for which application that is inserting or updating the records withSELECT APP_NAME()If app is yours, execute the result in the trigger, if not, exit...Peter LarssonHelsingborg, Sweden |
 |
|
|
|
|
|
|