Hi @Analyst_SQL ,
You could refer Guoxiong's method using WHILE loop with WAITFOR DELAY.
Or refer below simple example:
WHILE 1=1
BEGIN
INSERT INTO tbl_BalPacM (OrderNo,Order_Ref_No,PType,Date,PStatus,IPaddress,Etime,Chck_Status)
VALUES (22,'AS-102',1,cast(getdate() as date),1,'192.168.10.10',cast(getdate() as time(7)),'scn')
WAITFOR DELAY '00:00:10.000';
END
Actually one better solution is to use a SQL Agent job and schedule it for every ten seconds.
You have to create one job with insert statement and use the stored procedure sp_add_schedule to create the schedule. The parameter @freq_subday_type = 0x2 sets a daily recurrence to seconds and @freq_subday_interval = 10 makes it ten seconds.
For example:
EXEC sp_add_schedule 'every10seconds', 1, 4, 4, 0x2, 10
You could also refer Create and Attach Schedules to Jobs for more details.
In addition, you'll need to keep an eye on logging since every 10 seconds is 6 times more log entries than every minute.
Best regards,
Melissa
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.