none
How to return more columns and more rows with VARBINARY column in R script? RRS feed

  • Question

  • In my R script for MS SQL Server I try to return one column VARBINARY() and one VARCHAR(). However, server allow only one column when VARBINARY is returned:

    There can be only one column in the result set when using the 'varbinary' data type.

    Example code:

    EXEC sp_execute_external_script @language =N'R',
        @script=N'R,
        ff = tempfile();
        png(filename=ff, width=800, height=800);
        plot(...);
        dev.off();
        f1 = file(ff,"rb");
        d1 = readBin(f1, what=raw(), n=1e6);
        dd = data.frame(d1, c("plot1");
        colnames(dd) = c("plot", "title");
        OutputDataSet = dd;',
        @input_data_1 =N'SELECT * FROM table_name'
        WITH RESULT SETS ((plot varbinary(max)), (dsc varchar(20));

    Additionally I can't add new row to be returned.

    Wednesday, May 20, 2020 6:22 PM