I am trying to write a table to a non-default schema in SQL Server 2017. I am using RStudio\'s documentation as to what the best practice is for doing this: https://db.rstud
DBI 1.1.0 overcomes this issue.
dbWriteTable(con, SQL("schema.newTbleIris"), iris)
In my case, doing dbWriteTable(con, "[schema].newTbleIris", iris) without wrapping any function around worked.
I've found an easy workaround for this. Just follow through these steps:
First, write your table with a default schema:
dbWriteTable(con, "newTbleIris", iris)
And insert it into a new one with a non-default schema, but this time using the dbGetQuery function:
dbGetQuery(con, "SELECT * INTO [schema].newTbleIris FROM newTbleIris")
And that's it! Your table will now appear with a non-default schema.
Now you can remove the first table you first created with a default schema by doing
dbGetQuery(con, "DROP TABLE newTbleIris")