[Recommended] is SQL Server capable of regularly executing SQL statements to update databases?

Source: Internet
Author: User

Does SQL Server regularly execute SQL statements to update databases?
I have encountered such a problem, for example.
When a user registers for a website, the user's registration date is recorded in the database table, and the table also has a field ds: the number of days from the user registration day to the day. For example, if a user registered on July 15, January 01 and reaches on July 15, January 02, the user's ds should be changed to 1.
How to add the user's ds value to 1 at the next day?

There are many problems like this. I don't know how to deal with them? I used to think like this: when you need to use the ds value of a user, update the ds column in the database table. What do you think?
Thank you!

========================================================== ==================================
Use a JOB to regularly execute a statement ~~

========================================================== ==================================
Formulation of scheduled jobs

Enterprise Manager
-- Manage
-- SQL Server proxy
-- Right-click a job
-- Create a job
-- Enter the job name in "general"
-- "Step"
-- New
-- Enter the step name in "Step name"
-- Select "Transact-SQL script (TSQL)" in "type )"
-- "Database": select the database for Command Execution
-- Enter the statement to be executed in "command:
EXEC stored procedure name... -- this stored procedure is used to create a table

-- OK
-- "Scheduling" item
-- Create Scheduling
-- Enter the scheduling name in "name"
-- Select your job execution schedule in "scheduling type"
-- If "repeated appears" is selected"
-- Click "change" to set your schedule

Then start the SQL Agent service and set it to Automatic startup. Otherwise, your job will not be executed.

Setting method:
My computer -- control panel -- Administrative Tools -- service -- Right-click SQLSERVERAGENT -- properties -- start type -- select "auto start" -- OK.

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.