Connecting to SQL-Azure using FreeTDS
I've spent the last couple of days trying to connect SQL-Azure on Ubuntu 12.04 using FreeTDS, 90% of my pain has come from the goddam office firewall and it is actually quite a simple task.
I've compiled FreeTDS with libiconv and openssl so we can use it with the awesome tiny_tds gem.
Install
sudo wget ftp://ftp.astron.com/pub/freetds/stable/freetds-stable.tgz sudo tar -xvf freetds-stable.tgz cd freetds-stable sudo apt-get install gcc libssl-dev ./configure --prefix=/usr/local --with-libiconv-prefix=DIR --with-openssl=DIR --with-tdsver=7.3 sudo make sudo make install
After this you should be able to run:
$ tsql -C
And get:
Compile-time settings (established with the "configure" script) Version: freetds v0.91 freetds.conf directory: /usr/local/etc MS db-lib source compatibility: no Sybase binary compatibility: no Thread safety: yes iconv library: yes TDS version: 5.0 iODBC: no unixodbc: no SSPI "trusted" logins: no Kerberos: no
Connect
When connecting to SQL-Azure you need to be sure you are using the correct version of TDS and that your ip address is allowed on the firewall
$ TDSVER=8.0 tsql -H servername.database.windows.net -U username -D databasename -p 1433 -P password
That's it you should be connected to SQL-Azure and ready to hookup your rails app with tiny_tds
Troubleshooting
Confirm the installation
Confirm you can reach the sqlserver















