Working folders, logs and sessions for sp_execute_external_script

When running with R code and sp_execute_external_script it is very handy to know where all the output log files are being generated and what additional information about the session is available and which folders are useful when working with external stored procedure sp_execute_external_script.

Session information is stored on your local disk under location:

C:\Program Files\Microsoft SQL Server\MSSQL13.SQLSERVER\MSSQL\ExtensibilityData

with subfolders: \SQLSERVER01\2EDE2133-E0A1-42A9-8F1E-958E87AB92B5

2016-07-20 19_51_10-SQLSERVER2016RC301

These folders consist of subfolders and files of sessions ID. Nature of this folders is that they are purged after the session is closed – it can be from 6 to n-minutes. On my client I have by default 6 minutes. After this time, the sessions are closed and if you rerun the sp_execute_external_script from SSMS you will notify a slight delay because the R engine needs to re-establish all the sessions again in comparison of running the same script one time after another time.

The session file includes following RevoScaleR code:

sessionDirectory <- 'C:\\PROGRA~1\\MICROS~2\\MSSQL1~1.SQL\\MSSQL\\EXTENS~1\\SQLSERVER01\\C13E33C2-A71D-4ED3-AA13-B79BB2A1FBC1';
sessionId <- 'C13E33C2-A71D-4ED3-AA13-B79BB2A1FBC1';
scriptFile <- file.path(sessionDirectory, paste(sessionId, '.R', sep=''));
rxIgnoreCallResult <- .Call('RxSqlSessionStart', list(sessionDirectory=sessionDirectory, sessionId=sessionId, waitTime=-1));


Those who wanted to capture the output and log file that R engine usually generates. With sp_execute_external_script these files can not be navigated to, since procedure is a CLR and using preassigned assembly, even though the script is sent to R engine using CMD batch. This peace of information can be found on in file: C:\Program Files\Microsoft SQL Server\MSSQL13.SQLSERVER\MSSQL\Binn\rlauncher.config and for my configuration the content is as following:

RHOME=C:\Program Files\Microsoft SQL Server\MSSQL13.SQLSERVER\R_SERVICES
MPI_HOME=C:\Program Files\Microsoft MPI

These are all the global settings for R engine that is ran from SQL Server 2016 engine. And assembly to support R engine is located:

C:\Program Files\Microsoft SQL Server\MSSQL13.SQLSERVER\MSSQL\Binn\RLauncher.dll.

which is also the name of the service:

2016-07-20 20_39_01-Services


And finally, by running:

exec sp_helpextendedproc sp_execute_external_script

With this procedure one can find out that sp_execute_external_script is presented as dll.

2016-07-20 20_55_14-roles_security_sp_execute_external_Script.sql - SICN-00031_SQLSERVER2016RC3.mast

Happy T-SQLRing! πŸ™‚


*Blog post might change due to new/better information regarding this topic! This will be marked in accordance.

Tagged with: , , , , ,
Posted in Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Follow TomazTsql on

Tomaz doing BI and DEV with SQL Server and R

attaining enlightenment with sql server, .net, biztalk, windows and linux

SQL DBA with A Beard

He's a SQL DBA and he has a beard

DB NewsFeed

Matan Yungman's SQL Server blog

Reeves Smith's SQL & BI Blog

A blog about SQL Server and the Microsoft Business Intelligence stack with some random Non-Microsoft tools thrown in for good measure.

SQL Server

for Application Developers

Clocksmith Games

We make games we love to play

Business Analytics 3.0

Data Driven Business Models

SQL Database Engine Blog

Tomaz doing BI and DEV with SQL Server and R

Search Msdn

Tomaz doing BI and DEV with SQL Server and R


Tomaz doing BI and DEV with SQL Server and R

Ms SQL Girl

Julie Koesmarno's Journey In Data, BI and SQL World


R news and tutorials contributed by (750) R bloggers

Data Until I Die!

Data for Life :)

Paul Turley's SQL Server BI Blog

sharing my experiences with the Microsoft data platform, SQL Server BI, Data Modeling, SSAS Design, Power Pivot, Power BI, SSRS Advanced Design, Power BI, Dashboards & Visualization since 2009

Grant Fritchey

Intimidating Databases and Code

Madhivanan's SQL blog

A modern business theme

Alessandro Alpi's Blog

SQL Server, Azure and .net in a nutshell :D

Paul te Braak

Business Intelligence Blog

Sql Server Insane Asylum (A Blog by Pat Wright)

Information about SQL Server from the Asylum.

Gareth's Blog

A blog about Life, SQL & Everything ...

SQLPam's Blog

Life changes fast and this is where I occasionally take time to ponder what I have learned and experienced. A lot of focus will be on SQL and the SQL community – but life varies.

William Durkin

William Durkin a blog on SQL Server, Replication, Performance Tuning and whatever else.

$hell Your Experience !!!

As aventuras de um DBA usando o Poder do $hell

%d bloggers like this: