我正在尝试从 Rstudio 连接到 SQL Server。我收到以下错误。
> odbc::odbcListDrivers()
name attribute value
1 ODBC Driver 13 for SQL Server Description Microsoft ODBC Driver 13 for SQL Server
2 ODBC Driver 13 for SQL Server Driver /usr/local/lib/libmsodbcsql.13.dylib
3 ODBC Driver 13 for SQL Server UsageCount
library(odbc)
con <- DBI::dbConnect(odbc::odbc(),
Driver = "ODBC Driver 13 for SQL",
Server = "130.440.220.502",
Database = "CI_Temp",
UID = "user_x",
PWD = rstudioapi::askForPassword("Database password"),
Port = 1433)
Error: nanodbc/nanodbc.cpp:983: 00000: [unixODBC][Driver Manager]Can't open lib 'driver' : file not found
任何帮助将不胜感激。 预先感谢
您需要使用Driver =“ODBC Driver 13 for SQL Server”
library(odbc)
con <- DBI::dbConnect(odbc::odbc(),
Driver = "ODBC Driver 13 for SQL Server",
Server = "130.440.220.502",
Database = "CI_Temp",
UID = "user_x",
PWD = rstudioapi::askForPassword("Database password"),
Port = 1433)
我选择
Driver = "SQL Server"
,它对我有用。