Skip to Content.
Sympa Menu

freetds - HOWTO on setting up FreeTDS on a FreeBSD machine to connect to an MS SQL 7

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Gil Cohen" <cohengil4 AT hotmail.com>
  • To: freetds AT franklin.oit.unc.edu
  • Subject: HOWTO on setting up FreeTDS on a FreeBSD machine to connect to an MS SQL 7
  • Date: Thu, 21 Sep 2000 10:23:48 -0400


Hi guys, I actually wrote this a while ago, and thought I should contribute
it.

07-27-00
Problem:
Connecting to the MS SQL server from the FreeBSD server.

Preqs:
DBI:: installed.
---
gmake installed. If you do not have gmake installed, follow these directions:
cd /usr/ports/devel/gmake
make install
---


First get FreeTDS from:
ftp://ftp.metalab.unc.edu/pub/Linux/ALPHA/freetds/freetds-0.50.tgz or
http://www.freetds.org. tar -zxvf the file that you

downloaded. Go into that directory and use the following commands:
<under bash>
----------
./configure --with-tdsver=4.2 --enable-msdblib
gmake
gmake install
TDSVER=42
TDSPORT=1433
SYBASE=/usr/local/freetds
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$SYBASE/lib
export SYBASE LD_LIBRARY_PATH TDSVER TDSPORT
----------

I wouldn't bother trying to test anything out, they all fail. Now we've got
to go get DBD::Sybase from

http://search.cpan.org/search?module=DBD::Sybase. tar -zxvf that file. Now go
into the dir and use these commands:
<under bash>
----------
perl Makefile.PL
make
make install
----------
Don't worry if some of the tests fail. Now you've got to make some changes to
your /usr/local/freetds/interfaces file to suit

your environment, here's ours:
----------
SQLSERV
query tcp fxp0 192.168.0.1 1433
master tcp fxp0 192.168.0.1 1433
---------
The first line is the name of the server, ie, how you refer to it in perl
scripts.
-
The second line tells that the 'query' server uses tcp, and the network
interface that's used to get to it is fxp0 and the IP

address is 192.168.0.1 and the port is 1433 (this is the default port for MS
SQL server).
-
The third line says that the 'master' server uses tcp, and the network
interface that's used to get to it is fxp0 and the IP

address is 192.168.0.1 and the port is 1433 (this is the default port for MS
SQL server).

I don't understand why we need a query or master server thingamajig. I guess
it just has to be there.
Here's an example perl program:
use DBI;
$ENV{'SYBASE'} = '/usr/local/freetds'; # i think this line is needed.
$user = "gil";
$passwd = "mirthra"; # this isn't real!
$dbh = DBI->connect('dbi:Sybase:server=SQLSERV', $user, $passwd) # connect to
the SQL server named SHOPLOOP in the interfaces

file
or die 'connect';
$dbh->do("use STORES"); # switch to the database STORES ( in SQL)
$sth = $dbh->prepare('select * from S100') or die 'prepare'; # get ready to
run this statement
$sth->execute or die 'execute'; # execute the statement
while (@data = $sth->fetchrow_array) { # get a row and stick it in the array
@data (@#data contains the number of columns in

the output
print "$data[2]\n"; # get the third row of the output that was put into
@data
}
$sth->finish; # finish up.
$dbh->disconnect; # disconnect
---
In your .bashrc, so that perl scripts and all that shit works put this:
TDSVER=42
TDSPORT=1433
SYBASE=/usr/local/freetds
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$SYBASE/lib
export SYBASE LD_LIBRARY_PATH TDSVER TDSPORT




Archive powered by MHonArc 2.6.24.

Top of Page