How to read an SQL file in R?

449    Asked by Ajit yadav in Data Science , Asked on Nov 9, 2019
Answered by Ajit yadav

SQL file can be read by connecting to a database and it completely depends on the type of database that we use. One such library is RODBC. To connect the database, we can use the following

Install and load the library

install.packages("RODBC")

# RODBC Example of syntax

library(RODBC)

Establish a connection

myconn <-odbcConnect("Database_Name", uid="User_ID", pwd="password")

dat <- sqlFetch(myconn, "Table_Name")

querydat <- sqlQuery(myconn, "SELECT * FROM table")

close(myconn)



Your Answer

Interviews

Parent Categories