Srijan Blog

Freetds - A boon for *nix geeks

0 Comment(s)Oct 12, 2007

I am always fascinated by the work which involves some challenges and of course which can be passed onto others for a good cause and reason. Recently while working on project for some client, we were required to write an ongoing migration script. Since the source server database is running on MSSQL 2000 and the target server database is running on MYSQL 5.x.x, the hurdles that we need to cross involved :

  • To establish a connection with MSSQL database.
  • To write an ongoing migration script with check to avoid duplication of records and that too to fit with in the work flow and data structure for Drupal.

This part of my post will explain the way to build a bridge to let the *nix communicate with MSSQL.

After browsing through all the possibilities enlisted by google. I found there is no match against the FREETDS to build the bridge for data migration. For all non-techie guys "FreeTDS is a set of libraries for Unix and Linux that allows your programs to natively talk to Microsoft SQL Server and Sybase databases". Technically speaking, FreeTDS is an open source implementation of the TDS (Tabular Data Stream) protocol used by these databases for their own clients. It supports many different flavors of the protocol and three APIs to access it. Additionally FreeTDS works with other software such as Perl and PHP, providing access from those languages as well.

Where can i get the freetds file?

Download the latest stable version of freetds here

How to build: Configure and make

$ ./configure --prefix=/usr/local/freetds
$ make
$ su root
Password:
$ make install

After configuring and making the file you need to test if the freetds is working or not. To start with you can use tsql -H hostname -p port -U username -P password .Once the connection is established successfully you can use with any scriptig language. In my case I am using php5. For getting in depth knowledge, poke into freetds