I have a problem with running SQL query from R-Studo code.
On another machine everything works perfectly. I just try to run the same code from new computer
(RStudio version 2022.07.2)
IMP_Sales <- dbGetQuery(ImperialODBC, "Select SBLOC,SBCUST,SBSMNO,SBITEM,SBTYPE,SBINDT,SBPHYP,SBQSHP,SBEPRC,SBPRIC,SBICST,SBINV,SBCOSTPC,SBUM,SASHIP
+ From R50FILES.VSADETL
+ JOIN R50FILES.VSAHEAD
+ ON SBCMP=SACMP and SBORD=SAORD and SABOCD=SBBOCD
+ Where SBINV<>999999999 and SBPCOD <> 'LS' and SBCMP = 1 and SBPHYP between 202201 and 202212 and SBITEM <> ''")
and get the following error message:
Error: nanodbc/nanodbc.cpp:1655: HY000:
<SQL> 'Select SBLOC,SBCUST,SBSMNO,SBITEM,SBTYPE,SBINDT,SBPHYP,SBQSHP,SBEPRC,SBPRIC,SBICST,SBINV,SBCOSTPC,SBUM,SASHIP
From R50FILES.VSADETL
JOIN R50FILES.VSAHEAD
ON SBCMP=SACMP and SBORD=SAORD and SABOCD=SBBOCD
Where SBINV<>999999999 and SBPCOD <> 'LS' and SBCMP = 1 and SBPHYP between 202201
and 202212 and SBITEM <> '''
The dbConnect works without any problem
Please advice