Connecting to MSFT SQL Server Using R and odbc on Mac OSX

Adding this here to save the steps for when I need to setup additional Mac machines or need to update one. The purpose of setting this up is to be able to connect to MSFT SQL Servers from a Mac directly from R.

  1. Install homebrew if not already installed.
  2. Install the version of the driver that you want to use. I use ODBC Driver 17 for SQL Server.
  3. Tell R where to find the driver by adding the path to the .Renviron file. To find the location of this file, run:
    R.home(component = "home")
    in R. Then, add this line to the .Renviron file
    . (Note that you should “show hidden files” if you’re using Mac’s Finder.)
  4. Close R and start a new session. You should be good to go.