I am trying to execute a SQL query with dplyr on SQL Server:
tbl(con, sql(sqlQuery))
The request is generated dynamically with sprintf("SELECT ... WHERE a = '%s'). This is bad practice because it can be used for SQL injection, but I cannot find any documentation or a working example for parameterized queries in dplyr. Can this be done, how?
Connection ( con) uses the DBI, the odbc library, and the ODBC driver {SQL Server Native Client 11.0}:
con <- DBI::dbConnect(odbc::odbc(),
Driver = "{SQL Server Native Client 11.0}",
source
share