This article through the illustrated way to show you the SQL Server database table records only keep the N-day text tutorial, concrete method steps please see below:
First step: Set up the SQL Server Agent service to start automatically:
Start--> Control Panel--> Administrative Tools--> Services--> Right-click SQL SERVER Agent--> Properties--> Startup Type, select Auto Start--> OK, as shown in the following illustration:, R
Step two: Start the SQL Server Agent service, as shown in the following illustration:
Step three: Open Microsoft SQL Server Management Studio --> Connect to your database-select jobs under the SQL Server Agent node, as shown in the following illustration:
Step Fourth: Right, "new job"--> "General", as shown in the following figure:
Step Fifth: Then add the steps , as shown in the following illustration:
Step Sixth: an example of a SQL statement that retains only 10 days of data table records : Delete from table name where DateDiff (Day,cast (SUBSTRING [Time], 1, 8) as DateTime), GETDATE ()) > 10
Seventh step: Diagram of SQL Server database table records only keep the N-day method