我想将数据框导出到mssql表。我使用下面的代码,但我想设置目的地而不仅仅是服务器和表名。我在服务器内部有几个DB,我该如何保存其中一个中的表?
df<-read.csv(file.choose(),header = T,sep= T)
DB= odbcConnect(dsn ='R_BISRV',uid = 'XXXX', pwd = 'XXX')
sqlSave(DB, df, tablename = 'Tanya', rownames = F,append = T)
close(DB)
答案 0 :(得分:0)
我明白了:
数据库名称应位于odbcDriverConnect()
sqlSave()
和表名称中
channel <- odbcDriverConnect('driver={SQL Server};server=YYY;database=YY;port=1433;
uid=XX;pwd=XXX')
# Client systems use TCP 1433 to connect to the database engine
sqlSave(channel = channel,dat = df, rownames = TRUE, tablename = "Tanya")