Skip to content
Prev 244 / 1559 Next

binding variable in sqlQuery

Dear Sir/Madam,

How can we bind a variable value with sqlQuery. For example:

i am trying to run following command ::

library(RODBC)
inchannel <- odbcConnect("my_server", uid="samay")
sqlQuery(inchannel, 'select item1, item2 from _my_table
            where item3 >= 10
            and dbid = 10')

however for introducing flexibility i want to write this command as

my_value = 10
library(RODBC)
inchannel <- odbcConnect("my_server", uid="samay")
sqlQuery(inchannel, 'select item1, item2 from _my_table
            where item3 >= 10
            and dbid = my_value')


How can I bind the my_value with the query in sqlQuery?

Please suggest and help me. I am in need.