select * from openquery ( oracle, 'select * from tablename1')
---这适用于sql server
我使用了RODBC
包
fd1 <- sqlQuery(dbhandle, 'select *
FROM t1') -- This works
fd2 <- sqlQuery(dbhandle, 'select *
FROM openquery (Oracle, "select * from tablname1 where id is null")')
---这很有效。但是当我调用对象fd2
时,我得到以下内容 -
[1]“42000 102 [Microsoft] [ODBC SQL Server驱动程序] [SQL Server]'select * from tablename1 where id为null'附近的语法不正确。”
[2]“[RODBC]错误:SQLExecDirect无法从openquery中选择*(oracle,\”select * from tablename1,其中id为null \“)'”
如何解决这个问题?
答案 0 :(得分:0)
fd2在嵌入式SQL查询周围使用双引号。 T-SQL需要单引号。这样做:
fd2 <- sqlQuery(dbhandle,
'select * FROM openquery (Oracle, \'select * from tablname1 where id is null\')')