ansek ansek - 2 months ago 29
R Question

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]'

Answer

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