更新时间:2023-02-05 22:54:18
尝试如下切换NOCOUNT
:
old_qry <- "
DECLARE @tbl_IDs TABLE
(
Country nvarchar(30),
CID nvarchar(5),
PriceID int,
WindID int
)
INSERT INTO @tbl_IDs
VALUES
('Germany', 'DE', 112000001, 256000002);
SELECT * FROM @tbl_Ids
"
##
new_qry <- "
SET NOCOUNT ON;
DECLARE @tbl_IDs TABLE
(
Country nvarchar(30),
CID nvarchar(5),
PriceID int,
WindID int
);
INSERT INTO @tbl_IDs
VALUES
('Germany', 'DE', 112000001, 256000002);
SET NOCOUNT OFF;
SELECT * FROM @tbl_Ids
"
R> sqlQuery(tcon, gsub("\\n", " ", old_qry))
#character(0)
R> sqlQuery(tcon, gsub("\\n", " ", new_qry))
# Country CID PriceID WindID
#1 Germany DE 112000001 256000002
基本上,您想在代码的开头SET NOCOUNT ON
,而在最后一个SELECT
语句之前的SET NOCOUNT OFF
.
Basically you want to SET NOCOUNT ON
at the beginning of your code, and SET NOCOUNT OFF
just before the final SELECT
statement.