EDIT for Windows
Try
x = "PASS" SQL<- paste0("select ID, NAME, STATUS from STUDENT where STATUS = ", shQuote(x, 'sh')) Q1 <- dbGetQuery(con, SQL)
In general, shQuote is useful for built things, such as:
paste0("SELECT * FROM urtable where urvar IN(", paste0(shQuote(LETTERS, 'sh'), collapse = ','), ")") [1] "SELECT * FROM urtable where urvar IN('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z')" #
If you have simple character strings. More complex character strings may require different approaches. For example, in PoSTgreSQL, you can use Dollar-Quoted String Constants to remove characters.
You will not indicate which SQL option you are using or bundled the R package. Some R packages may have helper functions, such as postgresqlEscapeStrings in RPostgreSQL or dbEscapeStrings in RMySQL .