How to Insert,Update and delete through script without using merge.I have simple requirement of Deleting,Inserting and Update from one table to other tableHere is the Sample DataCREATE TABLE #Table1 (ID INT ,Name VARCHAR(30),DATEKEY INT)INSERT INTO #Table1 (ID,Name,DATEKEY)VALUES (1,'Mohan',20131231)INSERT INTO #Table1 (ID,Name,DATEKEY)VALUES (2,'Raj',20131231)INSERT INTO #Table1 (ID,Name,DATEKEY)VALUES (3,'Majja',20131231)INSERT INTO #Table1 (ID,Name,DATEKEY)VALUES (4,'Majjaa',20131231)CREATE TABLE #Table2 (ID INT ,Name VARCHAR(30),DATEKEY INT)
My query : INSERT INTO #Table2(ID,Name,DATEKEY)Select ID,Name,DATEKEY From #Table1
My Result will be like this : ID Name DATEKEY1 Mohan 201312312 Raj 201312313 Majja 201312314 Majjaa 20131231
So now i need to update 1st record and add another new record So i need to update as well as delete the existing data in Target table.INSERT INTO #Table1 (ID,Name,DATEKEY)VALUES (5,'Macha',20131231)My output should come like this one : ID Name DATEKEY1 Mohan 201312315 Macha 20131231
with out using merge how can i handle Update,insert and Delete through TSQLP.V.P.MOhan