Tutorial: Publish an R function as a SQL Server stored procedure with the sqlrutils package

August 8, 2017

(This article was first published on Revolutions, and kindly contributed to R-bloggers)

In SQL Server 2016 and later, you can publish an R function to the database as a stored procedure. This makes it possible to run your R function on the SQL Server itself, which makes the power of that server available for R computations, and also eliminates the time required to move data to and from the server. It also makes your R function available as a resource to DBAs for use in SQL queries, even if they don't know the R language.

Neils Berglund recently posted a detailed tutorial on using the sqlrutils package to publish an R function as a stored procedure. There are several steps to the process, but ultimately it boils down to calling registerStoredProcedure on your R function (and providing the necessary credentials).


If you don't have a connection (or the credentials) to publish to the database yourself, Niels also explains how to use the StoredProcedure function to generate a SQL Server source file defining a stored procedure including your R function, which you can provide to a DBA to deploy.

You can find the complete tutorial, including detailed explanations of the various parameters, at the link below.

Niels Berglund: Creating R Stored Procedures in SQL Server 2016 Using sqlrutils


To leave a comment for the author, please follow the link and comment on their blog: Revolutions.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.

Search R-bloggers


Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)