Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
These are VERY basic instructions for getting MS SQL Server working via ODBC on Mac OSX Snow Leopard, with rails. It assumes you know how to make / install libraries from source. It took a LOT of trial and error so your results may vary.
1. Install unixODBC
Get from
./configure --prefix=/usr/local --enable-gui=no
sudo make install
2. Install FreeTDS
Get from
Notice that you are configuring it to point to the location you specified above, where you installed unixODBC, and using the tds version 8.0 so that it works with the latest MS SQL Server.
./configure --prefix=/usr/local --with-tdsver=8.0 --with-unixodbc=/usr/local
sudo make install
3. Test TSQL
Make sure that tsql is installed correctly.
tsql -C
You should see it compiled with unixODBC, if not or if it shows you compiled with iODBC, sudo make uninstall both packages and try again.
4. Set up config files in /usr/local/etc
host = [SERVER NAME / IP]
port = 1433
tds version = 8.0
Driver = /usr/local/lib/
*note: verify that the .so is in the location above. If you configured as I showed, then you should be fine.
Driver = FreeTDS
Server = [SERVER]
Database = [DATABASE] // optional, you might want to specify your database in your yml.
Port = 1433
TDS_Version = 8.0
5. Test with iSQL
isql is installed with unixODBC. You can use it to make sure the DSN is setup properly. After you launch isql, you should be able to send sql commands to the server and see results.
isql [DSN_NAME] [username] [password]
If this doesn't work, but tsql -C was correct, then check your config files and make sure you can really get to your server via TCP/IP.
6. Set up Ruby ODBC to work with unixODBC
Get Ruby ODBC here:
Configure with ruby config pointing to the usr/local directory.
ruby ext/extconf.rb --with-odbc-lib=/usr/local
sudo make install
In my experience, don't use the gem ruby-odbc. This isn't compiled to use unixODBC.
7. Install activerecord-sqlserver-adapter
gem install activerecord-sqlserver-adapter
I'm using version 2.3.8 which doesn't require the dbi or dbd-odbc gems.
After this you should test your rails app with a rake db:migrate or other methods to see if your server gets set up properly.
email if you have any questions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment