Automatically delete a day of data

xiaoxiao2021-04-03  226

- Create a job

Enterprise manager

--management

--SQL Server Agent

- Right-click job

- New homework

- Enter the job name in "General" item

- "Step" item

- New

- Enter the step name in "Step Name"

- Select "Transact-SQL Scripts (TSQL)" in "Type"

- "Database" Select the database that executes commands

- Enter the statement you want to perform in "Command":

DELETE FROM table Where Times <= dateadd (day, -1, getdate ())

--determine

- "Scheduling" item

- New dispatch

- Enter the schedule name in "Name"

- Select your job execution arrangement in "Scheduling Type"

- If you choose to "repeatedly appear"

- Click "Change" to set your schedule

Then start the SQL Agent service and set to automatically start, otherwise your job will not be executed.

Setting method:

My Computer - Control Panel - Administrative Tools - Services - Right-Right-Right-Right-Start Type - Select Auto Start - OK.

转载请注明原文地址:https://www.9cbs.com/read-131555.html

New Post(0)