- SQL Server 2017 Machine Learning Services with R
- Toma? Ka?trun Julie Koesmarno
- 159字
- 2025-02-20 14:20:36
Using XP_CMDSHELL
This method is by far the fastest and is very useful when sharing T-SQL code, but it compromises using the command shell and many users and DBAs are not keen on this. By enabling xp_cmdshell in configurations and using this stored procedure, you can install any missing package. Using code with the -e switch, you can easily install the library:
R cmd -e install.packages("Hmisc")
The following code will install the missing package on the R Server:
-- enable xp_cmdshell EXECUTE SP_CONFIGURE 'xp_cmdshell','1'; GO RECONFIGURE; GO EXEC xp_cmdshell '"C:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\R_SERVICES\bin\R.EXE"cmd -e
install.packages(''Hmisc'')'; GO
Running Vanilla R and adding the install.packages() function can be done if the user has been granted the permission. The results are as follows:

Using CMD and the -e switch, the deployment and computation of R code can be executed and simplified, but since this is not an official way I would not suggest using this, since it exposes security issues.