我使用以下内容成功查询第一台服务器所需的内容:
library(RODBC)
library(data.table)
library(sqldf)
library(zoo)
library(forecast)
library(plyr)
library(parallel)
myconn <- odbcDriverConnect("SERVER=SQL12p4;DRIVER=SQL Server")
ManagementHours <- sqlQuery(myconn, " SELECT .......")
但是,当我尝试连接到其他服务器SQL12P4\VSQL1
时,我无法连接。我知道\
是一个逃避角色,我相信这是我的问题。我想知道是否有办法解决这个问题?下面是我目前使用的R命令。
myconn1 <- odbcDriverConnect("SERVER=SQL12P4\VSQL1;DRIVER= SQL SERVER")
> myconn1A <-odbcDriverConnect("SERVER=SQL12P4\VSQL1;DRIVER= SQL SERVER")
Error: '\V' is an unrecognized escape in character string starting ""SERVER=SQL12P4\V"
> myconn1B <-odbcDriverConnect("SERVER=SQL12P4\\VSQL1;DRIVER= SQL SERVER")
Warning messages:
1: In odbcDriverConnect("SERVER=SQL12P4\\VSQL1;DRIVER= SQL SERVER") :
[RODBC] ERROR: state IM002, code 0, message [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
2: In odbcDriverConnect("SERVER=SQL12P4\\VSQL1;DRIVER= SQL SERVER") :
ODBC connection failed