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.