installinglanguage extensions in SQL 2019

Harry Coenen 1 Reputation point
2021-09-23T09:52:38.033+00:00

Hello,

got language extensions from github:
https://github.com/microsoft/sql-server-language-extensions

And tried several variations of the following:

CREATE EXTERNAL LANGUAGE [HR]
FROM (CONTENT = N'C:\temp\110R-lang-extension-windows-release.zip',
FILE_NAME = 'libRExtension.dll',
ENVIRONMENT_VARIABLES = N'{"R_HOME": "C:\Program Files\R\R-4.1.0","PATH":"C:\Program Files\Microsoft SQLServer\MSSQL15.MSSQLSERVER\MSSQL\ExternalLanguages\1\65552"}');
GO

followed by the test:

EXEC sp_execute_external_script
@language =N'HR',
@script=N'
print(R.home());
print(file.path(R.home("bin"), "R"));
print(R.version);
print("Hello RExtension!");'
;

With error message:
Msg 39004, Level 16, State 20, Line 94
A 'HR' script error occurred during execution of 'sp_execute_external_script' with HRESULT 0x80004004.

So ran out of ideas on this one.

Any ideas here?

Greetings
Harry

Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,596 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Harry Coenen 1 Reputation point
    2021-09-23T17:23:34.027+00:00

    Hello,

    Got it working with R4.0.3 and R.4.1.1.

    Install R with admin rights
    Start C:\Program Files\R\R-4.1.1\bin\x64\R.exe with admin rights
    install.packages("Rcpp", dependencies = TRUE, lib="C:\Program Files\R\R-4.1.1\library");
    pick a repo and install

    Add 'C:\Program Files\R\R-4.1.1\bin\x64' (wh quotes) to PATH
    Create System variable R_HOME 'C:\Program Files\R\R-4.1.1' (wh quotes)

    start CMD with admin rights:
    icacls "C:\Program Files\R\R-4.1.1" /grant "NT Service\MSSQLLAUNCHPAD":(OI)(CI)RX /T
    icacls "C:\Program Files\R\R-4.1.1" /grant *S-1-15-2-1:(OI)(CI)RX /T

    Restart Launchpad service

    CREATE EXTERNAL LANGUAGE [HR]
    FROM (
    CONTENT = N'C:\temp\110R-lang-extension-windows-release.zip'
    , FILE_NAME = 'libRExtension.dll'
    );

    test with:
    EXEC sp_execute_external_script
    @language =N'HR',
    @script=N'
    print(R.home());
    print(file.path(R.home("bin"), "R"));
    print(R.version);
    print("Hello RExtension!");'
    ;

    That's it.
    In short read the docs at:
    https://learn.microsoft.com/en-us/sql/machine-learning/install/custom-runtime-r

    Greetings
    Harry

    0 comments No comments

  2. EchoLiu-MSFT 14,581 Reputation points
    2021-09-24T01:54:30.94+00:00

    Hi @Harry Coenen

    Welcome to the microsoft tsql Q&A forum!

    I have no experience with this type of problem, so I did a simple search, and
    I found a similar problem, the method someone provided is as follows:
    You will need to install the software package to the SQL Server instance. There are various ways to install unavailable software packages to the SQL Server instance.

    You will choose the method suitable for you depending on your setup.

    If you are working on a local machine then you would want to download the Windows Binaries (zip file) of the package and install using T-SQL.

    For more details, please refer to:

    SQL 2016 with R - Error HRESULT 0x80004004

    If you have any question, please feel free to let me know.

    Regards
    Echo


    If the answer is helpful, please click "Accept Answer" and upvote it.
    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