I wish to query tables that are NOT in the default SQL Server 2012 database.

At work I am using SQL Server 2012 and Windows 7. I tested the following 
on my home set up of Server 2012 and Windows 7. I am using RStudio.

I wish to connect to several SQL Server 2012 databases from R.

This page helped me get started.

http://andersspur.wordpress.com/2013/11/26/connect-r-to-sql-server-2012-and-14/ 


I set up my connection with TSQLFundamentals2008 as the default database.

I then read in the table dbo.orders with the following code.

> library(RODBC)

> con = odbcConnect("SQLServer2012")

> orders1 = sqlFetch(con,"dbo.orders")

> odbcClose("SQLServer2012")

Error in odbcClose("SQLServer2012") :

argument is not an open RODBC channel

>

> head(orders1)

It appears to have worked properly. But I do not know what the error 
message means.

Now for the problem. I also want to read in the table dbo.sports. That 
table is in the database sportsDB. I did not see any way to do so from 
within R.

I could not find the answer in ODBC Connectivity by Brian Ripley, 
November 25, 2013.

Any ideas?

Are there alternative strategies such as using dplyr or data.table? The 
work tables may have hundreds of thousands of rows.

Thanks.


	[[alternative HTML version deleted]]

