
上QQ阅读APP看书,第一时间看更新
2.4 读取SQL Server数据库数据
首先安装RODBC包,再使用RODBC包。

我们可以先将本书的IRIS_Data数据库附加至MS SQL Server中(注意需将防火墙端口打开,并在SQL Server配置管理器中启用TCP/IP)。在Windows操作系统环境中可使用RODBC包读取Microsoft SQL Server数据库中的数据。
我们也可以在CentOS操作系统环境中使用RODBC包读取Microsoft SQL Server数据库中的数据。
调用odbcConnect()函数连接IRIS_Data数据库:

调用sqlQuery()函数读取iris表格(Table)内的数据:

显示前6笔数据:
