I am trying to run a simple R sum in R-Services using the parameters handed to a stored procedure but I do not know how to do it, nor find a good example. This is what I have so far:
IF OBJECT_ID ( 'TEST', 'P' ) IS NOT NULL
DROP PROCEDURE TEST;
GO
CREATE PROCEDURE TEST @a int = 0, @b int = 0 AS
BEGIN
EXEC sp_execute_external_script
@language = N'R'
,@script = N'print(sum(@a, @b))' -- how to pass params here?
,@input_data_1 = N'@a'
return @a + @b;
END
EXEC dbo.TEST @a = 2, @b = 3
GO
My question is how to pass the variables read in the stored procedure (@a
and @b
) to the R script?