[R] Error in sqlCopy in RODBC

BKMooney bkmooney at gmail.com
Mon Dec 1 16:41:50 CET 2008


The exact syntax I am running in R is as follows:

query <-  " select * from tblHistorical where MyDate between '2008-11-21'
and '2008-11-25' ; "
sqlCopy(RemoteChannel, query, "NewTable", destchannel=LocalChannel,
safer=TRUE, append=TRUE, rownames=FALSE, fast=FALSE)

Both RemoteChannel and LocalChannel seem to be functioning as expected for
getting data into R via the sqlQuery function.  It is writing data that is
giving me problems, as I am running into the same error with both the
sqlSave and sqlCopy functions.  

There are two scenarios - when "NewTable" does not exist in the local
database, and when it does.  


If "NewTable" does not exist, then I get the error:
Error in sqlSave(destchannel, dataset, destination, verbose = verbose,  : 
  unable to append to table ‘NewTable’

If "NewTable" exists, then I get the error:
Error in sqlSave(destchannel, dataset, destination, verbose = verbose,  : 
  [RODBC] ERROR: Could not SQLExecDirect
42000 102 [Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax
near '16'.

My select statement functions exactly as I would expect it to when I run it
as a query both in the SQL Management studio, or if I run it as a query
using sqlQuery, so I am fairly confident any syntax problem is not with that
query.  


If anyone has any ideas or suggestions, I would be very appreciative.  


-- 
View this message in context: http://www.nabble.com/Error-in-sqlCopy-in-RODBC-tp20691929p20774378.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list