Hi Varun, Basically when we are pulling data from linked server through SSMS/some other client tools we may need to use query like this format * linkedservername.databasename.schemaname.tablename* and in this case your query like this,
table1 <- as.data.table(sqlQuery(dbhandle, 'select * from linkedservername.databasename.schemaname.tablename')) Manu. On Tue, Sep 13, 2016 at 8:29 PM, Jeff Newmiller <jdnew...@dcn.davis.ca.us> wrote: > This is not an R concept, and it may be highly specific to the SQL Server > API rather than the ODBC API. You might try doing as the Posting Guide > recommends and posting in the R-sig-db mailing list. I would also recommend > that you figure out from Microsoft documentation what programming API your > GUI software example is using to accomplish this rather than referring to > that GUI program in your question. > -- > Sent from my phone. Please excuse my brevity. > > On September 13, 2016 7:02:20 AM PDT, Varun Sinha < > sinha.varun...@gmail.com> wrote: > >Hi All, > > > >I would like to know how to connect to a "linked server" from R. I find > >the > >linked server under Server Objects > Linked Servers on SQL management > >studio. > > > >Here is the current way I am using to connect to the server: > > > >dbhandle <- odbcDriverConnect('driver={SQL > >Server};server=servername;database=databasename;trusted_connection=true') > > > >table1 <- as.data.table(sqlQuery(dbhandle, 'select a, b from table1')) > > > >Could you please let me know the syntax to do the same but with the > >linked > >server instead? I would like to connect to a database on the linked > >server > >and run the query to pull data. > > > >Thank you for your help. > > > >Best regards, > >Varun > > > > [[alternative HTML version deleted]] > > > >______________________________________________ > >R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > >https://stat.ethz.ch/mailman/listinfo/r-help > >PLEASE do read the posting guide > >http://www.R-project.org/posting-guide.html > >and provide commented, minimal, self-contained, reproducible code. > > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/ > posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- Thanks, Manohar Reddy P +91-9705302062. [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.