0

I have looked at the following thread and its related links for RODBC help when it comes to passing an argument to sqlQuery: Pass R variable to RODBC's sqlQuery with multiple entries?

I have a function that takes in a year argument as a data table and the function will run smoothly when only one year is used as a filter but not if multiple years are inputted.

What's weird is that the function ran on my PC smoothly using multiple year filter before but now I'm getting the following error when I run it now:

42S02 208 [Microsoft][ODBC SQL Server Driver][SQL Server]Invalid object name 'Output'.[RODBC] ERROR: Could not SQLExecDirect 'select * from ##Output'

I have all of my ODBC set up correctly, I think, that's why it runs when sqlQuery is only filtered with one year.

If someone could explain to me any possible reason why the function is not running on a multiple year argument would be great.

el_
  • 13
  • 1
  • 4
  • `Output` is a [reserved word in SQL Server](https://learn.microsoft.com/en-us/sql/t-sql/language-elements/reserved-keywords-transact-sql). Perhaps you can escape it as `[Output]` or `"Output"` instead? – r2evans Sep 19 '17 at 17:57
  • @r2evans Thanks for the response. I actually just edited my error to reflect the correct table name I was trying to produce which is ##Output. I'm not sure if this would still bring up the same issue as you've mentioned above. – el_ Sep 19 '17 at 19:52
  • It is still a reserved word (even with the double-has, I think). Try sandwiching it in brackets or double-quotes, such as `[##Output]`. – r2evans Sep 19 '17 at 19:53

0 Answers0