in reply to Connecting to MS SQL Server from linux
I do this all the time. I couldn't get DBD::Sybase to fly for me, so I use DBD::ODBC.
First, you need to get unixODBC (either from your distro's packages or from here) (I've heard that iODBC also works but I haven't tried it).
You also need FreeTDS (your distro might not package this one). When building it, you'll want to pass "--with-unixodbc" to the configure script. You might also want to pass "--with-tdsver=7.0" if you've got MSSQL 7, or "--with-tdsver=8.0" if you've got SQL 2000 (haven't tried it with 2005 but I assume it'll work with 8.0). Build and install FreeTDS, and then you can set up your configs.
Assuming you passed "--prefix=/usr/local --sysconfdir=/etc" to your configure scripts, your configs should look something like this. Adjust paths to taste.
/etc/freetds.conf
[global] # skip misc freetds settings... [myserver] host = sql.example.com port = 1433 tds version = 8.0 # do tds version = 7.0 if SQL 7
/etc/odbcinst.ini
[FreeTDS] Description = FreeTDS MS SQL Server Driver Driver = /usr/local/lib/libtdsodbc.so Setup = /usr/local/lib/libtdsS.so
/etc/odbc.ini
[mydb] Description = My Example Database Driver = FreeTDS Servername = myserver # Servername should be the name of the section in freetds.conf Databse = mydb
Then install DBD::ODBC from CPAN, and connect with DBI->connect('dbi:ODBC:mydb', $username, $password)
|
|---|