Skip to content

Instantly share code, notes, and snippets.

@toamitkumar
Created April 12, 2011 04:10
Show Gist options
  • Save toamitkumar/914901 to your computer and use it in GitHub Desktop.
Save toamitkumar/914901 to your computer and use it in GitHub Desktop.
The steps for setting *nix server to connect to SQL Server:
1) Install the following binaries:
i) MyODBC-unixODBC
ii) unixODBC
iii) unixODBC-devel
2) Download and install FreeTDS (freetds-dev)
The ./configure step of FreeTDS is dependent on unixODBC being installed: ./configure -with-unixodbc=/usr/local
configure FreeTDS
Add a section to /etc/freetds/freetds.conf
FreeTDS : ./configure --with-tdsver=8.0 --with-unixodbc=/usr/ (command)
3) Ruby ODBC binding (http://www.ch-werner.de/rubyodbc/ruby-odbc-0.9997.tar.gz).
ruby extconf.rb
make
sudo make install
4) Install the following gems
gem install dbd-odbc
gem install dbi
gem install activerecord-sqlserver-adapter
gem install deprecated (2.0.1)
5) Create DB Definition
i) Edit /usr/local/etc/odbc.ini and /etc/unixODBC/odbc.ini:
[sql_server_def]
Description = FreeTDS
Driver = FreeTDS
Server = <server ip>
Database = <database name>
Port = 1433
ii) Edit /usr/local/etc/odbcinst.ini and /etc/unixODBC/odbcinst.ini:
[FreeTDS]
Description = FreeTDS unixODBC Driver
Driver = /usr/local/lib/libtdsodbc.so
Driver64 =
Setup = /usr/lib/unixODBC/libtdsS.so
Setup64 =
UsageCount = 1
CPTimeout =
CPReuse =
6) database.yml
development:
adapter: sqlserver
mode: dblib
dataserver: my_sql_server
database: my_database_name
username: my_username
password: xxxxx
timeout: 5000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment