At my work I have R-Studio (Microsoft R Open 3.2.5) installed and would like to connect to a Microsoft SQL Server database, to run scripts using the tables I have.
Something like this should work:
library(RODBC)
dbconnection <- odbcDriverConnect("Driver=ODBC Driver 11 for SQL Server;Server=YourDBName\\SQLEXPRESS; Database=TestDB;Uid=; Pwd=; trusted_connection=yes")
initdata <- sqlQuery(dbconnection,paste("select * from MyTable;"))
odbcClose(dbconnection)
Check out these links:
RODBC odbcDriverConnect() Connection Error
https://andersspur.wordpress.com/2013/11/26/connect-r-to-sql-server-2012-and-14/
Finally, make sure SQL Server has all proper permissions applied.