I know how to get odbc connection
odbcChannel <- odbcDriverConnect("DRIVER={driver name};SERVER=server name;Database=db name;
Uid=;Pwd=;trusted_connection=yes")
But I don't know how to refer table and columns from that connection. Now I need fetching columns from 3 tables from that server and database , how can I "translate" SQL query to meet R syntax below ?
Set @id = 1234
create table abc as
select run.run_id as 'ID', run.qtr_ind as 'Quarter', vdr.pro_id, prod.prod_name
from DBAPM01.dbo.t_vendor as vdr,
DBAPM01.dbo.t_product as prod,
DBAPM01.dbo.t_qtr_run as run
where
vdr.run_id = @id and
prod.prod_id = vdr.prod_id and
run.run_id = vdr.run_id
group by vdr.prod_id, prod.prod_name, run.qtr_ind
order by prod.prod_name