Skip to content
Prev 309116 / 398506 Next

Package RODBC sqlQueries

On Oct 26, 2012, at 11:02 AM, Steven Ranney <steven.ranney at gmail.com> wrote:

            
Try something like this. You generally should use double quotes for both and escape the inner double quotes so that they are retained in the character vector passed. Finally, it looks like you are getting newline characters in to the SQL query passed, presumably because your code is on multiple lines. Note the \n's in the error message.


# Build the query using ?paste

Query <- paste("SELECT tblDataFieldRawSiteVisit.*", 
               "FROM tblDataFieldRawSiteVisit", 
               "WHERE (((tblDataFieldRawSiteVisit.dataForm)=\"Oyster Transition Plan",
               "Site Mapping Detail\"));")


testData <- sqlQuery(db, Query)


It is also possible that you may not need to use the final semi-colon.

Regards,

Marc Schwartz