1
Answer

How can I move all the records more than 10days from main table to ano

Ram M

Ram M

2y
600
1

Hi everyone, please help me with this....
How can I move all the records more than 10days from main table to another table every day

Answers (1)
2
Jignesh Kumar

Jignesh Kumar

30 39.5k 2.9m 2y

Hello,

you can create shedular task which runs every day. In that task you can write your logic to insert data into another table from main table and you can delete data from main table. Please refer below script which may help you to do that

 Begin Transaction
 Insert into AnotherTableName (field1, field 2......) SELECT (field1, field2......) FROM MainTableName WHERE 
  DT_INSERT >= DATEADD(DAY, -10, GETDATE());
 Delete FROM MainTableName  WHERE DT_INSERT >= DATEADD(DAY, -10, GETDATE());
    
 Commit;