I have a list which has to pass one of it's elements to a SQL Server Query, While in R list elements will be in double quotes, SQL Server will not accept double quotes in a query as pattern. So I need to remove double quotes and add single quotes when adding to query. I have tried several solutions but failed .
i.e. categories <- c('Casual','Formal','Night-Wear','Others','Party','Sports')
str_input5 <- categories ycategoryDF1 <- sqlQuery(con,paste0("select year(sales_data.sold_date) as Year, sum(sales_data.net_pay) as Revenue FROM item_data,sales_data where sales_data.item_id = item_data.item_id and item_category = ",paste(cat(str_input5))," group by year(sales_data.sold_date) order by Year"))
it is showing
NULL in place of
str_input5. I need to get
str_input5 value as
'Night-Wear'. There are no other errors in this: while I am trying static values i am getting accurate result.
Thanks in advance, V L Sudhakat Inampudi