CREATE PROC [dbo].[sp_ExecuteJobProcsLocal]
AS

DECLARE @recId INT
		,@procName VARCHAR(50)
		,@procParams VARCHAR(250)

DECLARE localJobCursor CURSOR FOR
	
	SELECT	J.recId
			,J.procName
			,J.procParams
	FROM	pal_JobProcsLocal J
	WHERE	todo = 1

	OPEN localJobCursor      
		FETCH NEXT FROM localJobCursor INTO @recId,@procName,@procParams
    
	WHILE @@FETCH_STATUS = 0 
	BEGIN 
		DECLARE @query VARCHAR(MAX)

		SET	@query = 'EXEC ['+@procName+'] '+@procParams+''

		--PRINT @query
		EXEC(@query)

		UPDATE	J
			SET	todo = 0
		FROM	pal_JobProcsLocal J
		WHERE	recId = @recId

		FETCH NEXT FROM localJobCursor INTO @recId,@procName,@procParams       
	END   

CLOSE localJobCursor      
DEALLOCATE localJobCursor
