[R] DBI::dbWriteTable syntax error apparently from quotes

Eric Berger ericjberger at gmail.com
Tue Aug 29 11:21:44 CEST 2017


I have been successfully using RODBC for a long time (years) to connect to
MS SQL Server from R.
This week I wanted to try using odbc but I am seeing some problems which
may be related to how I set up my driver and/or connection.
The dbWriteTable manual page gives as an example command:

dbWriteTable( pDB$con, "mtcars", mtcars[1:5,])

When I try this I get the following error

Error: <SQL> 'CREATE TABLE "mtcars" (
  "row_names" varchar(255),
  "mpg" FLOAT,
  "cyl" FLOAT,
  "disp" FLOAT,
  "hp" FLOAT,
  "drat" FLOAT,
  "wt" FLOAT,
  "qsec" FLOAT,
  "vs" FLOAT,
  "am" FLOAT,
  "gear" FLOAT,
  "carb" FLOAT
)
'
  nanodbc/nanodbc.cpp:1587: 42000: [FreeTDS][SQL Server]Incorrect syntax
near 'mtcars'.

I believe that the complaint is related to the double quotes around
"mtcars" (and presumably the other double quotes in the command).
I tried searching to see if others have had this problem but I could not
find anything.

Thanks

	[[alternative HTML version deleted]]



More information about the R-help mailing list