Search code examples
rsql-serverodbcdriverrodbc

R connection to SQL Server


I have been trying to make a connection between R and the SQL server but I keep getting this error msg: object 'C_RODBCDriverConnect' not found

It seems as if R is trying to find that object but is failing in doing so, anyone have an idea on how I can solve this issue? Reinstalling R is not an option as it's a work computer and I do not have the rights to do so. Also note that I am using the RODBC package as the odbc package doesn't want to install properly (I kept getting the zero non-exit error msg).

Thanks in advance.

Zachary


Solution

  • Just make sure you make a odbc connection in the odbc data sources and ensure you have done it correctly to the sql server database.

    library(RODBC)
    
    #ODBC_1 refer to Database you want to use
    con_ref = odbcConnect("name_of_connection")# name of connection is what you used in odbc connection setup
    
    
    #input data
    x <- sqlQuery(con_ref, "select * from db_name")