- Scale and performance: While R is open-source and free, R packages run single-threaded and can consequently only consume datasets that fit into available memory on the local machine. This memory constraint becomes a critical drawback as data sizes grow or when wishing to speed up execution.
- Integrating with applications: R code can be easily integrated with business applications in production but many enterprises end-up translating the R code into different languages in order to integrate it. This process is typically cumbersome, costly and error-prone and doesn’t support agile innovation. Enterprises need a simple way for applications to retrieve predictions, scores and plots, schedule R jobs and integrate it with existing application logic.
- Data movement: Moving data out of the database is best avoided when possible. Having to transfer data for analysis on a separate machine running R can present security headaches and latency issues when data volumes grow. It also tends to create data fragmentation because different people in the organization find themselves working on different versions of the data.
Apart from this; we have to facility to work on the large datasets which provides the multiple benefits-
- It brings the R applications to the production through the most familiar T-SQL interface. This is because most of the developers are aware about the T-SQL and they can easily integrate R with their T-SQL code and use it through the SQL Server.
- It avoids the need of data movement between our data and R computation and R computation will be running on the same server as the database in DB analytics. It facilitates to work on the same copy of the data in the data store.
- It provides a superior performance and scale for common operations, over open source R while allowing the use of any R package. It allows scaling for large datasets, far exceeding the available memory on the machine.
The primary benefit is secure, scalable analytics: R scripts run in isolated sessions managed by SQL Server's extensibility framework, preventing data leakage and leveraging parallel processing across server cores. Common use cases include data cleaning, feature engineering, model training, and predictive scoring—all without exporting data over networks.
History and Evolution
- SQL Server 2016: Launched as "R Services," focusing solely on R integration. It included Microsoft R Open (an enhanced open-source R distribution) and packages like RevoScaleR for scalable analytics.
- SQL Server 2017: Renamed to "Machine Learning Services" to add Python support. R capabilities were enhanced with newer runtimes and additional packages.
- SQL Server 2019–2022: Continued refinements, including support for more R packages and better integration with Azure. Microsoft R Open was retired, shifting to standard open-source R distributions.
- As of 2025: No major deprecations for R in Machine Learning Services, but starting with SQL Server 2022, R runtimes are not bundled in setup—users must install custom runtimes post-installation. Legacy packages like MicrosoftML (R), olapR, and sqlrutils are limited to SQL Server 2016–2019.
Key Features for R
Machine Learning Services provides a rich set of tools for R users:
| Feature | Description |
|---|---|
| In-Database Execution | Run R scripts via T-SQL using sp_execute_external_script, keeping data secure and reducing latency. |
| Scalable Packages | RevoScaleR for distributed processing of large datasets; supports rx functions for modeling and visualization. |
| Pre-Installed Packages | Includes base R, common open-source libraries (e.g., ggplot2, dplyr), and Microsoft-specific ones (version-dependent). Additional packages can be installed via R tools. |
| Parallel Processing | Automatic use of multiple cores for computations; hint with @parallel = 1 for certain operations. |
| Integration Tools | sqlrutils (older versions) for embedding R in stored procedures; support for MDX queries via olapR (deprecated in newer versions). |
R runtime versions vary by SQL Server edition:
| SQL Server Version | R Runtime Version |
|---|---|
| 2022 (RTM+) | 4.2.0 |
| 2019 (RTM+) | 3.5.2 |
| 2017 (CU22+) | 3.3.3 / 3.5.2 |
| 2017 (RTM–CU21) | 3.3.3 |
| 2016 | 3.2.2–3.5.3 (varies by update) |
Installation
Installation depends on your SQL Server version. Machine Learning Services must be selected during SQL Server setup (or added later via Add Features).
- For SQL Server 2016–2019 (Windows):
- Run SQL Server setup, select "R Services" (or "Machine Learning Services" in 2017+).
- Post-install, enable the feature on the instance: EXEC sp_configure 'external scripts enabled', 1; RECONFIGURE;
- Verify: EXEC sp_execute_external_script @language=N'R', @script=N'print("R is ready")';
- For SQL Server 2022+ (Windows/Linux):
- Install base SQL Server without runtimes.
- Download and install R runtime (e.g., via Rtools or custom packages) from CRAN or Microsoft sources.
- Register the runtime: Use sqlmlutils Python package or manual configuration.
- Enable external scripts as above.
- On Linux: Use mssql-mlservices-config tool.
For detailed steps, refer to official docs for your platform. Prerequisites include admin rights and sufficient disk space (R runtime ~1–2 GB).
References: Microsoft


Please go through my profile in linkedin.
ReplyDeletePlease let me know what are the prerequisite skills.
Kindly mail me at vidyapeeta@gmail.com
Mukesh,
ReplyDeleteI am interested in learning R to get my skills upgraded in IIoT. Please go through my profile in linkedin. Suggest me with your valuable advice. I cannot spend in $$$$ or lakhs of rupees Please