ansek
ansek

Reputation: 443

R Plot Rendering SQL Server 2016 Using sp_execute_external_script

Has anyone figured out how to render a plot using sp_execute_external_script where the plot is returned in the SQL Management Studio result window or the message window or a popup window? I was able to output a plot to the file system but that is not ideal.

Below is how I got a plot to output to the file system.

EXECUTE  sp_execute_external_script
                @language = N'R'
              , @script = N' trellis.device(device="png", filename="c:/output/HistPlot.png");
              myHist=histogram(~col1, data=InputDataSet);
              print(myHist)'
              , @input_data_1 = N'SELECT  col1, col2 from ds.dbo.[sample]'

Upvotes: 3

Views: 1944

Answers (3)

Cyrille Tijsseling
Cyrille Tijsseling

Reputation: 86

Until Microsoft provide visualization capability, you could use SSMSBoost which is a free utility that could solve your problem.

Once installed, please highlight the cell with the binary picture to be read. Right click and select Visualize as and then choose picture.

Right click and select Visualize as and then choose picture

The image is going to be displayed into Paint: The image is going to be displayed into Paint

Upvotes: 5

Umachandar - Microsoft
Umachandar - Microsoft

Reputation: 484

We are looking at providing visualization capability in SSMS for graphics returned from R script. But for now you have to open the image in an application that can display it (SSRS, Internet Explorer) and so on. MSDN has samples that show how to use the plots in SSRS. You can find the samples here.

Upvotes: 4

Ust Oldfield
Ust Oldfield

Reputation: 21

You probably want to use SSRS to display output in a plot. SSMS isn't designed to display graphics. You can display the output of a stored procedure in SSRS and the recent additions to SSRS in CTP3 means that you can produce some really nice looking charts.

Upvotes: 2

Related Questions