I am trying to import some data directly into R from a SQL Database. I have set up the connection without an issue but extracting the data has been somewhat challenging. I will try and make this as clear as possible because I don't think I can make it reproducible due to some sensitive information. When I run the following line I get the data I wanted:
myconn <- odbcConnect("COMPANYNAME", uid = "support", pwd = "password111?")
sqlQuery(myconn, "SELECT * FROM Metrics")
However, when I include a specific database I want to extract from within the server I get an issue:
sqlQuery(myconn, "USE companyname_clientname SELECT * FROM Metrics")
Where companyname_clientname is the database. Instead of the data I want, I get
character(0)
I know that introducing "USE companyname_clientname" is the issue, I just don't know why or how to fix it. If there is anything that would make this easier for you to help me let me know and I will accommodate.
FROM companyname_clientname.Metrics
be equivalent? – ImmoderateodbcConnect
, but that's just speculation. – ImmoderateodbcConnect
– HamonUSE
query separate from theSELECT
query? If so, does inserting a semicolon between the queries help? – Nabcharacter(0)
– Hamon