安装插件包
install.packages("RODBC")
连接数据库,查询表,打印数据
require('RODBC')
dbhandle <- odbcDriverConnect('driver={SQL Server};server=192.168.22.24;database=xxx;uid=xxx;pwd=xxx')
r <- sqlQuery(dbhandle, 'select top 1 * from table_name')
print(r)
关闭连接
odbcClose(dbhandle)