sql - RODBC 包 : How to get a logical value for the "Does the Table Exists?" query type?

标签 sql r rodbc

我正在尝试将 R/Shiny/SQL 应用程序转换为使用来自 SQL Server 而不是 Oracle 的数据。原代码中有很多如下类型条件:如果表存在,则将其作为数据集,否则上传新数据。我一直在寻找 DBI/ROracle 包中的 dbExistsTable 命令的对应项,但不幸的是 odbcTableExists 只是内部 RODBC 命令在 R 环境中不可用。也是 RODBC 包的包装器,允许使用 DBI 类型的命令 - RODBCDBI 似乎不起作用。有任何想法吗? 这是一些代码示例:

library(RODBC)
library(RODBCDBI)

con <- odbcDriverConnect('driver={SQL
    Server};server=xx.xx.xx.xxx;database=test;uid=user;pwd=pass123')

odbcTableExists(con, "table")

错误:找不到函数“odbcTableExists”

dbExistsTable(con,"table")

错误(函数(类,fdef,mtable): 无法为签名““RODBC”、“字符””找到函数“dbExistsTable”的继承方法

最佳答案

你可以使用

[Table] %in% sqlTables(conn)$TABLE_NAME

其中[Table]是您要查找的表的字符串。

关于sql - RODBC 包 : How to get a logical value for the "Does the Table Exists?" query type?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34755382/

相关文章:

mysql - 选择客户在 mysql 中仅获得红色汽车(不是红色和绿色两者)

php - mysql查询调整在百分比或固定类型佣金值保存在一列的情况下获取最高数量

c++ - postgreSQL 中 lo_import 的 SQL 准备语句是什么

r - 没有默认值的错误 : argument "x" is missing,?

R:按字母顺序重新排序因子的级别,但一个

r - 从 data.table 中选择具有最小值的行

SQL 服务器 2008 : updating and keeping tracking of anuual price increase

在 R 中以 64 位读取访问数据库 (mdb)

sql-server - 使用 RODBC 和 MS SQL Server 长时间运行的查询超时