首页 > 解决方案 > SQL Server R sript 的结果集中的更多 VARBINARY 列

问题描述

在我的 MS SQL Server 的 R 脚本中,我尝试返回一列 VARBINARY() 和一列 VARCHAR()。但是,当返回 VARBINARY 时,服务器只允许一列:

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

示例代码:

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));

如何使用 VARBINARY 列返回附加列?

标签: rsql-server

解决方案


推荐阅读