FreeTDS on FreeBSD 6.2
Connect to a Microsoft SQL Server via Perl from UNIX

Prerequisites:

FreeBSD (Base + Autoconf, Automake, Bash and GCC)
Perl Modules (DBI)

Overview:
 Step #1 - Download, Unzip, Untar, Configure, Compile and Install FreeTDS
 Step #2 - Download, Unzip, Untar, Configure, Compile and Install DBD::Sybase
 Step #3 - unixODBC (Not required for FreeTDS, but logical to install it now)

Step #1

FreeTDS - Free "Tabular Data Stream"

Home:

 http://www.freetds.org

# Change to your desired "source" storage directory
cd /usr/src

# Download (Notes: Users behind a Proxy Server should read this and users without Internet but have a CDRom read this.)

fetch http://ibiblio.org/pub/Linux/ALPHA/freetds/stable/freetds-stable.tgz
 
# Unzip and Untar

tar xvf freetds-stable.tgz


# Configure
cd freetds-0.64/
./configure --enable-msdblib --with-tdsver=8.0

#
 Compile & Install
make install clean


Step #2

DBD::Sybase

Home:

 http://www.peppler.org/freeware/dbd-sybase.html

# Change to your desired "source" storage directory
cd /usr/src


# Download

fetch http://www.peppler.org/downloads/DBD-Sybase-1.07.tar.gz

# Ungzip and Untar
tar xvf DBD-Sybase-1.07.tar.gz


# Change to the source directory
cd DBD-Sybase-1.07

# Set a few shell variables temporarily
SYBASE=/usr/local/
export SYBASE
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$SYBASE/lib
export LD_LIBRARY_PATH

#
 Add the needed environment variables (so it they survive reboots) to /etc/rc.local
vi /etc/rc.local

# Create the Makefile - press "Enter" on any questions to accept default settings
perl Makefile.PL

#
 Compile
make
# make test

#
 Install
make install clean

 

# Optional test script - safe to ignore / skip this
# Test a connection to a Microsoft SQL Server

# (You should already have a database called "test" a table "authors" a field "Name")

# Create a scripts directory if one does not already exist
cd /opt
mkdir scripts
cd /opt/scripts

# Create a script for testing
vi /opt/scripts/my.pl

# Make the script executable
chmod +x /opt/scripts/my.pl

# Run the script
/opt/scripts/my.pl

 


#
 Note: Edit freetds.conf to suit your needs
vi /usr/local/etc/freetds.conf


Step #3

unixODBC

Home:

http://www.unixodbc.org

# Install unixODBC from ports
cd /usr/ports/databases/unixODBC/
make install clean