Running job afte every 30 min to insert records using Store procedure. If records are more than sp should insert all records in within time. How can i achive this?? How to auto scale this procedure.
Loading
Running job afte every 30 min to insert records using Store procedure. If records are more than sp should insert all records in within time. How can i achive this?? How to auto scale this procedure.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Lokesh VarmanRank #374 · 6.8K reputationPosted Jul 13, 2023, 12:57 AM EDT
An example of how you can achieve the desired functionality using SQL Server as the database system:
1. Create SP
CREATE PROCEDURE InsertRecords AS BEGIN -- Insert your logic here to insert records into the relevant table(s) END2. Using SQL Server Agent, you can create a job that runs the stored procedure at regular intervals. An example of a job that runs every 30 minutes:
USE YourDatabase; -- Create the job EXEC msdb.dbo.sp_add_job @job_name = N'InsertRecordsJob'; -- Configure the job EXEC msdb.dbo.sp_add_jobstep @job_name = N'InsertRecordsJob', @step_name = N'Run InsertRecords', @subsystem = N'TSQL', @command = N'EXEC InsertRecords', @retry_attempts = 5, @retry_interval = 5; -- Schedule the job to run every 30 minutes EXEC msdb.dbo.sp_add_schedule @schedule_name = N'Every_30_Minutes', @freq_type = 4, @freq_interval = 1, @active_start_time = 000000; EXEC msdb.dbo.sp_attach_schedule @job_name = N'InsertRecordsJob', @schedule_name = N'Every_30_Minutes'; EXEC msdb.dbo.sp_add_jobserver @job_name = N'InsertRecordsJob';3. Within the stored procedure, implement error handling to handle any exceptions that may occur during the insertion process
CREATE PROCEDURE InsertRecords AS BEGIN BEGIN TRY -- Insert your logic here to insert records into the relevant table(s) END TRY BEGIN CATCH -- Handle the error here END CATCH ENDPraveen Mishra183 reputationPosted Jul 13, 2023, 4:31 AM EDT
You can do using simple logic of Query Store in SQL Server
ALTER DATABASE YourDatabaseName SET QUERY_STORE = ON;Prasad RaveendranRank #320 · 7.8K reputationPosted Jul 13, 2023, 9:39 PM EDT
Would you mind, if you could rephrase your question?