I\'m using RODBC package to access my sql database in R. I haven\'t been able to find any useful information on how to pass a vector from R to sql as a vector.
I want to try and figure out how to do this using R Notebook SQL chunk, but have not been able to figure it out. I had lots of trouble with other methods. This works for me.
library(RODBC)
myconn<-odbcConnect(dsn = "Data Source Name",
uid = rstudioapi::askForPassword("User ID"),
pwd = rstudioapi::askForPassword("Database password"))
id<-('00003', '00100') # vector of ID's
id<-paste0(personid, collapse = ", ") #create string for entry into query
query<-paste("select *
from prod_cust_vw.store_dim
where store_num in (", id,")", sep = "") #query -- use "paste". I have not tried with "paste0")
data<-sqlQuery(myconn,query) #obtain the data by applying the query through the connection.