The SQL SERVER database table records are retained for only N days.

Source: Internet
Author: User
Tags microsoft sql server management studio sql server management studio

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


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.