SqlServer database uses dynamic SQL to realize daily incremental deletion of table data
The requirement is to periodically delete 96 million pieces of data from the SqlServer database every day, use dynamic SQL to obtain the smallest ID in the source table, and add 95999999 on the basis of the smallest ID. Each time 10 million pieces of data are deleted, and the deleted records are deleted every time a delete record is executed. Data volume to track data deletion.
1. Create a new data deletion record table
CREATE TABLE IOTDAQ.dbo.del_info (
table_name nvarchar(100),
qty bigint,
date DATE