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

Jeff Newmiller jdnewmil at dcn.davis.ca.us
Tue Aug 29 15:43:15 CEST 2017


Double quotes are not legal SQL syntax. Use single quotes.
-- 
Sent from my phone. Please excuse my brevity.

On August 29, 2017 2:21:44 AM PDT, Eric Berger <ericjberger at gmail.com> wrote:
>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]]
>
>______________________________________________
>R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list