Sarvapindi Posted July 31, 2019 Report Share Posted July 31, 2019 Sql experts randi va..oka qn i have a table .. Table A... With 1000 records with columns below id. Name this table will be updated everyday...so some records will be deleted or some new records will be inserted. I want to find what are the records thats r inserted and records that r deleted everyday...and load those into another table... how to do Quote Link to comment Share on other sites More sharing options...
AndhraneedSCS Posted July 31, 2019 Report Share Posted July 31, 2019 Write a trigger and convert the inserts and deletes into an insert into the different table. 1 Quote Link to comment Share on other sites More sharing options...
BetterThief Posted July 31, 2019 Report Share Posted July 31, 2019 1 minute ago, Sarvapindi said: Sql experts randi va..oka qn i have a table .. Table A... With 1000 records with columns below id. Name this table will be updated everyday...so some records will be deleted or some new records will be inserted. I want to find what are the records thats r inserted and records that r deleted everyday...and load those into another table... how to do daily snapshot teesi data ni inko table lo pettu (Table B).. danito Table A data ni compare chesi neeku kavalsina table lo load cheyyi. Once load done delete records from Table B and reload it with Existing Table A data for next iteration. 2 Quote Link to comment Share on other sites More sharing options...
Sarvapindi Posted July 31, 2019 Author Report Share Posted July 31, 2019 Just now, AndhraneedSCS said: Write a trigger and convert the inserts and deletes into an insert into the different table. Hmm..actually that table gets loaded from a file... Quote Link to comment Share on other sites More sharing options...
JollyBoy Posted July 31, 2019 Report Share Posted July 31, 2019 3 minutes ago, Sarvapindi said: Hmm..actually that table gets loaded from a file... Both solutions will work Quote Link to comment Share on other sites More sharing options...
Sarvapindi Posted July 31, 2019 Author Report Share Posted July 31, 2019 1 minute ago, BetterThief said: daily snapshot teesi data ni inko table lo pettu (Table B).. danito Table A data ni compare chesi neeku kavalsina table lo load cheyyi. Once load done delete records from Table B and reload it with Existing Table A data for next iteration. gud ba..sql steps cheppu jara Quote Link to comment Share on other sites More sharing options...
BetterThief Posted July 31, 2019 Report Share Posted July 31, 2019 Just now, Sarvapindi said: gud ba..sql steps cheppu jara 10ge.. avi kooda rakunte etla vayya.. Inka DDL kooda ivvu manale. 2 Quote Link to comment Share on other sites More sharing options...
AndhraneedSCS Posted July 31, 2019 Report Share Posted July 31, 2019 It doesn't matter how the table gets populated. Trigger will fire up on insert/delete/update on your table,. All your trigger will do is populate this data into another table (call it dummy) and identify if it is an insert/update/delete and continue the operation on the main table. Your dummy table . will have all the information you may need and you just have to query it to see what inserts/updates/deletes ran on that table. if this is a mission-critical table that has 100s of transactions per second through out the day, this approach can cause performance bottleneck. Otherwise, it will work just fine. Quote Link to comment Share on other sites More sharing options...
Sarvapindi Posted July 31, 2019 Author Report Share Posted July 31, 2019 1 minute ago, BetterThief said: 10ge.. avi kooda rakunte etla vayya.. Inka DDL kooda ivvu manale. ave main ba Quote Link to comment Share on other sites More sharing options...
Chinna84 Posted July 31, 2019 Report Share Posted July 31, 2019 How u r loading file ?? Ssis ?? Quote Link to comment Share on other sites More sharing options...
Sarvapindi Posted July 31, 2019 Author Report Share Posted July 31, 2019 Just now, Chinna84 said: How u r loading file ?? Ssis ?? Azure datafactory.. Quote Link to comment Share on other sites More sharing options...
InSearch Posted August 1, 2019 Report Share Posted August 1, 2019 28 minutes ago, Sarvapindi said: Hmm..actually that table gets loaded from a file... Aa file ne source ga use chesukovachugaa... for your new table🤡 Quote Link to comment Share on other sites More sharing options...
Spartan Posted August 1, 2019 Report Share Posted August 1, 2019 CREATE TRIGGER name_table ON name AFTER UPDATE,INSERT AS BEGIN INSERT INTO name_change_history( id, old_name, new_name, date_of_change ) SELECT i.id, d.name, i.name, GETDATE() FROM inserted i LEFT JOIN deleted d ON i.id = d.id WHERE i.name != ISNULL(d.name, -1) END; Quote Link to comment Share on other sites More sharing options...
ranku_mogudu Posted August 1, 2019 Report Share Posted August 1, 2019 1 hour ago, Sarvapindi said: Sql experts randi va..oka qn i have a table .. Table A... With 1000 records with columns below id. Name this table will be updated everyday...so some records will be deleted or some new records will be inserted. I want to find what are the records thats r inserted and records that r deleted everyday...and load those into another table... how to do trigger Quote Link to comment Share on other sites More sharing options...
Katravelli Posted August 1, 2019 Report Share Posted August 1, 2019 2 hours ago, Spartan said: CREATE TRIGGER name_table ON name AFTER UPDATE,INSERT AS BEGIN INSERT INTO name_change_history( id, old_name, new_name, date_of_change ) SELECT i.id, d.name, i.name, GETDATE() FROM inserted i LEFT JOIN deleted d ON i.id = d.id WHERE i.name != ISNULL(d.name, -1) END; Super bro nuvvu Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.