The SQL SERVER database table records are retained for only N days.
This article shows you how to keep the SQL SERVER database table records for only N days. For detailed steps, see the following:
Step 1: first set the SQL Server proxy service to automatically start:
"Start" --> "Control Panel" --> "Management Tools" --> "service" --> right-click "SQL SERVER Agent" --> "properties" --> "Start type ", select "auto start" --> "OK", as shown in:
Step 2: Start the SQL Server proxy service, as shown in:
Step 3: Open Microsoft SQL Server Management Studio--> Connect to your database -- select "job" under the "SQL server proxy" node, as shown in:
Step 4: Right-click and choose "New job" --> "regular ",As shown in:
Step 5: Add steps, As shown in:
Step 6: An SQL statement example that only records data tables for 10 days is retained: Delete from table name where datediff (day, cast (SUBSTRING ([TIME], 1, 8) as datetime), getdate ()> 10
Step 7: Explain how to keep the SQL SERVER database table records for only N days