| |

VerySource

 Forgot password?
 Register
Search
Author: xyhhhh

Accumulate a number every ten seconds

[Copy link]

1

Threads

2

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

 Author| Post time: 2021-3-1 15:00:01
| Show all posts
The question is how to write Transact-SQL scripts and stored procedures
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2021-3-1 15:15:01
| Show all posts
Run the loop + waitfor delay instruction, it seems that it can also meet the demand
Reply

Use magic Report

0

Threads

93

Posts

46.00

Credits

Newbie

Rank: 1

Credits
46.00

 China

Post time: 2021-3-1 19:15:01
| Show all posts
Seems to be done only through homework
Reply

Use magic Report

0

Threads

114

Posts

69.00

Credits

Newbie

Rank: 1

Credits
69.00

 China

Post time: 2021-3-1 19:30:01
| Show all posts
UP,JOB
Reply

Use magic Report

0

Threads

8

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2021-3-1 19:45:01
| Show all posts
Homework completed
Otherwise, write the program to complete
Reply

Use magic Report

1

Threads

6

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2021-3-1 20:00:01
| Show all posts
Triggers can also be used :)
Reply

Use magic Report

0

Threads

28

Posts

25.00

Credits

Newbie

Rank: 1

Credits
25.00

 China

Post time: 2021-3-1 20:15:02
| Show all posts
Triggers can also be used :)
---Not suitable
Reply

Use magic Report

0

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2021-3-1 20:30:01
| Show all posts
Support job..........
Reply

Use magic Report

0

Threads

126

Posts

73.00

Credits

Newbie

Rank: 1

Credits
73.00

 China

Post time: 2021-3-1 21:00:02
| Show all posts
In addition to the JOB execution that everyone said, you can also use the following methods:

declare @Last_hour char(2)
select @Last_hour=convert(char(2),getdate(),108)
while 1=1 (loop execution, you can also decide whether to stop executing the process by accessing a certain global variable or a certain table parameter)
begin
    waitfor DELAY '00:00:10'-wait for 10 seconds
    update L set L=L+CAST(rand()*1000 as INT) FROM table. . (The rand()*1000 depends on the situation to define by yourself)
    IF @Last_hour<>convert(char(2),getdate(),108) one hour passed
    BGEIN
        Generate a record to the table
        select @Last_hour=convert(char(2),getdate(),108)
    END
end
   
In this way, the tasks to be performed on the hour may differ by 0-10 seconds
However, you can also move the task to be performed on the whole point to another process for execution. The algorithm is similar, which can reduce the time error.
Reply

Use magic Report

0

Threads

4

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2021-3-1 21:15:01
| Show all posts
The program can also be used, the timer event in the program
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list