Data Exploration and Predictive Modeling (Tutorial: SQL Server R Services)


MicrosoftSQL Server 2016 (CTP3) contains a preview version of R Services (In-database). This new product includes provides closer integration of R with enterprise data sources such as SQL Server databases.

In This Topic

  • Get the CTP3 Samples

    Link to downloadable data and sample scripts

  • Developing an End-to-End Data Science Solution

    Learn how to build a solution, deploy it to SQL Server, and perform scoring

  • SQL Server R Services for the Data Scientist

    Learn more about the enhanced packages provided by Microsoft R Open 3.2.2 and how to use them with SQL Server data

Get the CTP3 Samples

Product samples for SQL Server 2016 are available from the Microsoft Download Center:

SQL Server 2016 Product Samples

This download includes the AdventureWorks databases, as well as samples for new features such as Stretch Database.


To get only the samples for R Services (In-database), select the zip file, and open the folder Advanced Analytics.

Developing an End-to-End Data Science Solution

Data Science End-to-End Walkthrough

This solution uses the New York City Taxi data set to demonstrate the entire data science process:

  • Import data to SQL Server

  • Build a predictive model using R

  • Deploy the R model to SQL Server

  • Use the model in production for scoring

Start here if you want to learn how to use the new functions provided by the RevoScaleR package to work with SQL Server data in R.


For additional examples of how the New York City taxi dataset is used in machine learning, see Building Azure ML Models on the NYC Taxi Dataset.

SQL Server R Services for the Data Scientist

The following walkthrough, currently available in PDF format from the Microsoft Download Center, assumes that you are already familiar with the R language and want to learn how to use the new database integration features, such as the ability to change execution context.

Getting Started with RevoScaleR and SQL Server

The walkthrough explains the functionality of the new R packages and functions provided by Revolution R Enterprise 7.5.0, including:

  • Defining a SQL Server data source

  • Uploading data from a CSV file into a SQL Server database by using R

  • Using R to modify tables and add column metadata

  • Using the enhanced RevoScale R packages in SQL Server

  • Creating predictive models and storing them in SQL Server

  • Using stored models to generate predictions

Depending on your familiarity with R, the walkthrough should take between 60 and 90 minutes to complete.

Additional Samples and Blogs

This blog post outlines the process of using the R packages and functions provided by R Services (In-database) to connect to SQL Server. Sample code is provided.

Using R inside SQL Server


If you need more information about learning the R language, or want to learn more about the R packages provided in R Services (In-database), see these resources.

See Also

Getting Started with SQL Server R Services
SQL Server R Services Features and Tasks