I have connect Microsoft SQL Server 15 on Windows with a DSN name and i can see this connection in the connection window in Rstudio as the picture shows
But i want to take a specific table from this database AdventureWorks2019 -> Sales -> CreditCard for example ?
What command should i use in order to appear this table as a data frame or tibble in R and play with this data frame ?
I can what the table includes in the view script as you can see.
CodePudding user response:
You have to write a SQL Query and execute it.
You can use the odbc::dbGetQuery()
function.
Try this code :
my_dataframe <- odbc::dbGetQuery(conn = con, "SELECT TOP 1000 * FROM Sales.CreditCard")