我正在尝试使用RODBC库
运行以下查询 USE db
SET NOCOUNT ON
SET ANSI_WARNINGS OFF
DECLARE @table_name TABLE
(id int,
value int,
X nvarchar(30),
Y nvarchar(30),
Z BIT,
mth int,
org int)
DECLARE @cust TABLE (id INT IDENTITY(1,1),ck VARCHAR(100))
insert into @cust select ck from tableX where iA = 1
DECLARE @cnt INT = 1;
DECLARE @rowCount INT = (Select COUNT(*) FROM @cust)
DECLARE @return_value int
WHILE @cnt < @rowCount
BEGIN
DECLARE @temp VARCHAR(100) = (Select ck from @cust where id = @cnt);
INSERT INTO @table_name
EXEC [dbo].[testProcedure]
@nm = 6,
@ck = @temp
SET @cnt = @cnt + 1;
END;
SELECT * from @table_name
我已经尝试将类型为TABLE的变量交换到临时表,其中在临时表的情况下,它返回值时返回任何值 - 字符(空)。看了类似的问题并应用了所有建议的解决方案,如SET NOCOUNT ON或SET ANSI_WARNINGS OFF,都没有结果。
传递给R的sql查询与sqlserv完全相同。
dbhandle<- odbcDriverConnect('driver={SQL Server};server=xxxx;database=xxxx; Uid:xxxx; Pwd=xxxx')
query <- paste("sql query")
data2<- sqlQuery(dbhandle, query) - tried also with as.is parameter.
任何建议都非常感谢!感谢