I believe many friends will be attracted to SQL Server 2016 R language features, upgrade their own database to SQL Server 2016, but when you install SQL Server 2016 R language components, you will find that it is not directly used, For example, when you execute the following test R language command in SSMs, SQL Server 2016 will have various errors ...
execSp_execute_external_script@language =N'R', @script=N'Outputdataset<-inputdataset', @input_data_1 =N'Select 1 as Hello' withResult Sets (([Hello] int not NULL)); Go
I was also a long time to finally succeed in SQL Server 2016 executes the R language.
First, if you want to enable SQL Server's R language feature, you must start SQL Server Two services:
1.Sqlserver Instance Database Engine service:
2.Sqlserver Instance SQL Server Lanuchpad service:
After you start the two services, you also execute the following SQL script in SSMs to enable the ability to execute external scripting (r language) in SQL Server. Note the restart of the Database Engine service and the SQL Server Lanuchpad service will not take effect until this script is executed :
Exec sp_configure 'external scripts enabled'1; reconfigure;
If you install SQL Server 2016, if there are spaces in the installation path, then congratulations ... You also need to modify a system configuration file, no SQL Server 2016 R language runtime will error ...
For example, when I install SQL Server 2016, the installation path is D:\Program Files\Microsoft SQL Server\mssql13. MSSQLSERVER
Then locate the file D:\Program Files\Microsoft SQL Server\mssql13. Mssqlserver\mssql\binn\rlauncher.config
Start Notepad with operating system administrator rights (Notepad), open rlauncher.config, find working_directory This item is modified to a folder path without spaces, where I use a custom folder D:\ Rworkspace
Give D:\RWorkspace Full control of the Windows user Everyone (see article that actually gives this folder full control of the execution account of the SQL Server Lanuchpad service, but because I did not find SQL in the system Server Lanuchpad The execution account of the service, so this gives the user full control of everyone):
Then start command-line tool CMD as an administrator, navigate to the folder D:\Program Files\Microsoft SQL Server\mssql13. Mssqlserver\r_services\library\revoscaler\rxlibs\x64
To execute the cmd command:
Registerrext.exe/uninstall
The results are as follows:
Execute the cmd command again:
Registerrext.exe/install
The results are as follows:
Execute the above Test R language command again in SSMS:
EXEC Sp_execute_external_script@language=n‘r @script =n ' @input_data_1 =n ' with result Sets (([helloint not nullgo
As a result, the R language module runs successfully!
But because of the execution of Registerrext.exe/uninstall and Registerrext.exe/install, I found that these two commands actually end up in the Rlauncher.config file Working_ The path to directory is changed to D:\SQL-mssqlserver-ExtensibilityData, as shown in:
So before we modify the config file in rlauncher.config and give everyone Full control of the folder D:\RWorkspace the steps may be superfluous, But the ultimate goal is not to let the Rlauncher.config file working_directory path contains spaces, no, SQL Server 2016 R language runtime will error, this must be noted.
Well, the R language service can finally be used successfully, then you can explore the mysteries of SQL Server R language!
SQL Server R service environment installation error (PIT) workaround