I am trying to import some data directly into R from an SQL database. I made the connection without any problems, but retrieving the data was somewhat complicated. I will try to make this as clear as possible, because I donβt think I can make it reproducible due to some important information. When I run the following line, I get the data I need:
myconn <- odbcConnect("COMPANYNAME", uid = "support", pwd = "password111?") sqlQuery(myconn, "SELECT * FROM Metrics")
However, when I turn on a specific database that I want to extract from inside the server, I get a problem:
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 a problem, I just don't know why and how to fix it. If there is anything that will facilitate your help, let me know and I will accept.
source share