【问题标题】:getting the connection string for MS SQL Server 2008获取 MS SQL Server 2008 的连接字符串
【发布时间】:2013-06-08 10:22:49
【问题描述】:

我是 SQL 新手,不太清楚如何将 R 连接到 SQL 数据库。

我想使用 R 连接到数据库,但不确定字符串是什么才能做到这一点。

数据库不是本地的,而是在服务器上。

我对所有 CRAN 库持开放态度,但目前正在使用 RODBC,并且据我所知我可能需要使用以下命令。

library(RODBC)
channel <- odbcDriverConnect("")

library(RODBC)
channel <- odbcDriverConnect("some connection string i need")

library(RODBC)
channel <- odbcDriverConnect('driver=#not sure where to find this;server=#not sure where to find this either;database=#i think this would be the path to the database#;trusted_connection=true')

第一种方法在使用 R Gui 时会打开一个用户界面,但由于数据库没有存储在本地,而是在服务器上,所以找不到特定的表...

我可以访问当前使用 Microsoft SQL Server Management Studio (2008) 的数据库,并且觉得我可能能够找到所需的连接字符串来访问我需要的所有数据库,所以我猜我的问题是我需要在 Microsoft SQL Server Management Studio 中的哪个位置创建/构建/写入正确的连接字符串以访问相关数据库。

任何帮助将不胜感激,如果这是一个如此基本的问题,我们深表歉意。

提前致谢。

编辑

有关其他信息,这是组件名称和版本信息

Microsoft SQL Server Management Studio                      10.0.1600.22 ((SQL_PreRelease).080709-1414 )
Microsoft Data Access Components (MDAC)                     2000.085.1132.00 (xpsp.080413-0852)
Microsoft MSXML                     2.6 3.0 4.0 5.0 6.0 
Microsoft Internet Explorer                     8.0.6001.18702
Microsoft .NET Framework                        2.0.50727.3623
Operating System                        5.1.2600

编辑 2

我在输入以下命令时也会得到以下输出

> odbcDataSources()
                                      MS Access Database                                              Excel Files 
          "Microsoft Access Driver (*.mdb, *.accdb)" "Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)" 
                                         dBASE Files 
   "Microsoft Access dBASE Driver (*.dbf, *.ndx, *.mdx)" 

【问题讨论】:

标签: sql r sql-server-2008 connection-string rodbc


【解决方案1】:

这是我的一般方法(因为我也总是忘记怎么做)

  • 创建一个空文件,例如使用记事本,扩展名为 .udl,例如 SQLS.udl。
  • 双击它;应该会打开一个对话框,您可以在其中选择提供商等,并可以测试连接。
  • 确定后,打开文件并使用provider行;它大部分都有效。

【讨论】:

    猜你喜欢
    • 2013-01-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多