interact between user defined R functions in R services

Abhijat Singh 0 Reputation points
2023-04-17T21:53:23.64+00:00

Hello I am trying to use R-Services in my SQL Server 2017. After SQL passes the signal to R to start computing, the R part of the code needs to call several user defined R functions to arrive at the final output. In all there is a one big R script (that is invoked by SQL), which in turn calls about 10 user defined R functions , some of the also run in parallel. How do I set this all up? As an example :

EXECUTE sp_execute_external_script @language = N'R'
    , @script = N'R script containing user defined R functions'
    , @input_data_1 = N'SELECT settings from settings_table'
WITH RESULT SETS(([Hello World] INT));
GO

Any inputs will be appreciated as I started working on R-Services only a couple of days ago.

SQL Server Other
{count} votes

1 answer

Sort by: Most helpful
  1. Anonymous
    2023-04-18T06:07:31.9266667+00:00

    Hi @Abhijat Singh

    I'm not an expert on R-Services. If you need a tutorial, you can check out the official documentation.

    https://learn.microsoft.com/en-us/sql/machine-learning/tutorials/quickstart-r-create-script?view=sql-server-ver16

    In addition, you can also refer to this document.

    https://www.mssqltips.com/sqlservertip/4747/sql-server-spexecuteexternalscript-stored-procedure-examples/

    Best regards,

    Percy Tang


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". Note: Please follow the steps in our Documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.