Imato.CLR.ParallelRunner 1.0.1

dotnet add package Imato.CLR.ParallelRunner --version 1.0.1                
NuGet\Install-Package Imato.CLR.ParallelRunner -Version 1.0.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Imato.CLR.ParallelRunner" Version="1.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Imato.CLR.ParallelRunner --version 1.0.1                
#r "nuget: Imato.CLR.ParallelRunner, 1.0.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Imato.CLR.ParallelRunner as a Cake Addin
#addin nuget:?package=Imato.CLR.ParallelRunner&version=1.0.1

// Install Imato.CLR.ParallelRunner as a Cake Tool
#tool nuget:?package=Imato.CLR.ParallelRunner&version=1.0.1                

MS-SQL CLR - Imato.CLR.ParallelRunner

Helpers for start same procedures in parallel

How to use
  1. Compile Imato.CLR.ParallelRunner or dounload
  2. Register new assembly [Imato.CLR.ParallelRunner] in DB
CREATE ASSEMBLY [Imato.CLR.ParallelRunner]
FROM 'PathToDll\Imato.CLR.ParallelRunner.dll'
WITH PERMISSION_SET = UNSAFE;
go
  1. Create type SqlProcedure
CREATE TYPE dbo.SqlProcedure AS TABLE
(Id INT NOT NULL IDENTITY(1, 1) PRIMARY KEY,
SqlText NVARCHAR(MAX) NOT NULL,
IsSuccess BIT,
ErrorText NVARCHAR(MAX))
  1. Create function GetSqlProcedures
CREATE  FUNCTION dbo.GetSqlProcedures
  (@tableProcedures dbo.SqlProcedure READONLY)
RETURNS NVARCHAR(MAX)
AS
/*
  Need to prepare XML parameter @sqlProcedure in procedure dbo.RunParallel
*/
BEGIN
  RETURN (
    CAST((SELECT t.Id, t.SqlText
          FROM @tableProcedures t
          FOR XML PATH('Procedure'), ROOT('Root')) AS NVARCHAR(MAX)));
END
  1. Create procedure RunParallel
CREATE PROCEDURE dbo.RunParallel
  @sqlProcedures NVARCHAR(MAX),     -- List of procedures
  @noOutput      BIT            = 0, -- don't return result of execution,
  @maxThreads    INT            = 10

AS EXTERNAL NAME [Imato.CLR.ParallelRunner].[RunParallelProcedure].[RunParallel];
  1. Use it for start others procedures in parallel
Example
-- 1. Create list
DECLARE @commands dbo.SqlProcedure;

insert into @commands
(SqlText)
values
('print ''Test 1''; waitfor delay ''00:00:02'';'),
('waitfor delay ''00:00:02'';');

-- 2. Get parameter @sqlProcedures
DECLARE  @sqlProcedures nvarchar(max);
set @sqlProcedures = dbo.GetSqlProcedures(@commands);

-- 3. Execute
EXEC dbo.RunParallel @sqlProcedures = @sqlProcedures
    -- @noOutput = 0,
    -- @maxThreads = 10
;
Product Compatible and additional computed target framework versions.
.NET Framework net48 is compatible.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.1 166 10/6/2023
1.0.0 121 10/6/2023