This topic contains 3 replies, has 2 voices, and was last updated by
January 2, 2019 at 6:36 pm #132363ParticipantTopics: 1Replies: 1Points: 14Rank: Member
I am a newbie to PowerShell and trying to a build a script that does the following functionality. Could someone please help me with this?
I would like to setup a new PowerShell script that invokes my Database Stored Procedure concurrently. I am currently having a Control table that has a Job_ID column and a Code column. There might be more than one Job_ID for a code value in the Control table. Based on the code value I pass in the PowerShell along with a date, I would like the PowerShell to trigger the Stored Procedure which is expecting "Job_ID" and "MyDate" as input parameters.
FYI, I am using SQL Server 2016.
PS C:\PowerShell> $PSVersionTable.PSVersion Major Minor Build Revision ----- ----- ----- -------- 2 0 -1 -1
Here is some sample data for your reference:
CREATE TABLE control_table(JOB_ID INT, CODE VARCHAR(5)); INSERT INTO control_table(1, 'ABC'); INSERT INTO control_table(2, 'ABC'); INSERT INTO control_table(3, 'ABC'); INSERT INTO control_table(1, 'DEF'); INSERT INTO control_table(1, 'GHI'); CREATE PROCEDURE myschema.run_job (@JOB_ID INT, @MyDate DATE) AS BEGIN -- Do Something END
When I run the PowerShell script by passing 'ABC" as code, it should execute all the three jobs concurrently by reading the control table.
.\test.ps1 –MyCode “ABC” –Dt “12/27/2018”
January 3, 2019 at 12:21 am #132410ParticipantTopics: 0Replies: 78Points: 416Rank: Contributor
Please refer my blog post below, and you can use or customize as per your requirement...
January 3, 2019 at 8:10 pm #132617ParticipantTopics: 1Replies: 1Points: 14Rank: Member
Thank you for the reply. I couldn't find scripts that does asynchronous processing or run jobs concurrently. Please advise.
January 4, 2019 at 12:37 am #132650ParticipantTopics: 0Replies: 78Points: 416Rank: Contributor
Hi Julaayi – Can you put down your code? So that I can tweak it a bit as per your requirement. Thank you.
The topic ‘Execute concurrent processes using PowerShell’ is closed to new replies.