我正在尝试将名为“MyDF”的data.frame保存到名为“database2”的数据库中名为“MyTable”的表中。通道“con”打开与同一服务器上不同数据库的连接。我在下面尝试多次尝试在服务器上写回数据库2并获取错误。
在Attempt1中,代码在正确的数据库database2中创建一个名为MyTable的空表,然后抛出下面的错误。
最后一次尝试,Attempt7创建一个表并将记录加载到它中,但是在错误的数据库上创建它。
是否可以在database2上创建一个表并使用channel con将记录从MyDF加载到它中,或者我是否需要专门为database2创建一个新的通道?我只是使用channel con和sqlQuery从database2中提取数据时没有任何问题,只要我将[database2]。[dbo]添加到表名的开头。
data class DesugarExample(val foo: Int, val bar: Int, val baz: Int)
fun desugarIt() {
val (useFoo, dontCare, useBaz) = DesugarExample(1, 2, 3)
}
[RODBC]错误:无法SQLExecDirect'CREATE TABLE [database2]。[dbo]。[MyTable](“Field1”float,“Field2”float,“Field3”float,“Field4”float,“Field5”float ,“Field6”float,“Field7”float,“Field8”float,“Field9”float,“Field10”float,“Field11”float,“Field12”float,“Field13”float,“Field14”varchar(255))'
Attempt1:
sqlSave(con,MyDF,tablename="[database2].[dbo].[MyTable]",fast=F,append=F)
Error in sqlColumns(channel, tablename) :
‘[database2].[dbo].[MyTable]’: table not found on channel
Attempt2:
sqlSave(con,MyDF,tablename="[database2].[dbo].[MyTable]",fast=F,append=T)
Error in sqlSave(con, MyDF, tablename = "[database2].[dbo].[MyTable]", :
42S01 2714 [Microsoft][ODBC SQL Server Driver][SQL Server]There is already an object named 'MyTable' in the database.
[RODBC] ERROR: Could not SQLExecDirect 'CREATE TABLE [database2].[dbo].[MyTable] ("rownames" varchar(255), "Field1" float, "Field2" float, "Field3" float, "Field4" float, "Field5" float, "Field6" float, "Field7" float, "Field8" float, "Field9" float, "Field10" float, "Field11" float, "Field12" float, "Field13" float, "Field14" varchar(255))'
Attempt3:
sqlSave(con,MyDF,tablename="[database2].[dbo].[MyTable]",fast=T,append=T)
Error in sqlSave(con, MyDF, tablename = "[database2].[dbo].[MyTable]", :
42S01 2714 [Microsoft][ODBC SQL Server Driver][SQL Server]There is already an object named 'MyTable' in the database.
[RODBC] ERROR: Could not SQLExecDirect 'CREATE TABLE [database2].[dbo].[MyTable] ("rownames" varchar(255), "Field1" float, "Field2" float, "Field3" float, "Field4" float, "Field5" float, "Field6" float, "Field7" float, "Field8" float, "Field9" float, "Field10" float, "Field11" float, "Field12" float, "Field13" float, "Field14" varchar(255))'
Attempt4:
sqlSave(con,MyDF,tablename="[database2].[dbo].[MyTable]", verbose=TRUE, rownames= FALSE)
Query: CREATE TABLE [database2].[dbo].[MyTable] ("Field1" float, "Field2" float, "Field3" float, "Field4" float, "Field5" float, "Field6" float, "Field7" float, "Field8" float, "Field9" float, "Field10" float, "Field11" float, "Field12" float, "Field13" float, "Field14" varchar(255))
Error in sqlSave(con, MyDF, tablename = "[database2].[dbo].[MyTable]", :
42S01 2714 [Microsoft][ODBC SQL Server Driver][SQL Server]There is already an object named 'MyTable' in the database.
[RODBC] ERROR: Could not SQLExecDirect 'CREATE TABLE [database2].[dbo].[MyTable] ("Field1" float, "Field2" float, "Field3" float, "Field4" float, "Field5" float, "Field6" float, "Field7" float, "Field8" float, "Field9" float, "Field10" float, "Field11" float, "Field12" float, "Field13" float, "Field14" varchar(255))'
Attempt5:
sqlSave(con,MyDF,tablename="[database2].[dbo].[MyTable]", verbose=TRUE, rownames= FALSE,fast=T,append=T)
Query: CREATE TABLE [database2].[dbo].[MyTable] ("Field1" float, "Field2" float, "Field3" float, "Field4" float, "Field5" float, "Field6" float, "Field7" float, "Field8" float, "Field9" float, "Field10" float, "Field11" float, "Field12" float, "Field13" float, "Field14" varchar(255))
Error in sqlSave(con, MyDF, tablename = "[database2].[dbo].[MyTable]", :
42S01 2714 [Microsoft][ODBC SQL Server Driver][SQL Server]There is already an object named 'MyTable' in the database.