Pages

Friday, August 03, 2007

SQLServer: Setting up Access from UNIX

These are the detailed instructions for getting t-sql setup to run on UNIX.

This assumes that you have perl 5x installed, and CPAN as well....

  1. Update CPAN to the current available version
    1. cpan > install Bundle::CPAN
  2. Use CPAN to install the DBI::Bundle
    1. cpan > install Bundle::DBI
  3. Install Freetds
    1. Download files from here
    2. Gunzip and untar the freetds tar.gz file
    3. Read the README!
    4. Run configure tool to customize for your system
      1. ./configure
    5. Install freetds
      1. ./make install
    6. Add valid SQLServer info to /usr/local/etc/freetds.conf

      [{server_connection_name}]
        host = {server dns name or ip}
        port = {1433}
        tds version = 8.0

    7. Use CPAN to install the DBD::Sybase
      1. Set SYBASE environment variable to /usr/local
      2. cpan > force install DBD::Sybase
    8. Test the install with a perl connection script
Here's a test script to use (note: pass in in clear text):




#!/usr/bin/perl

#
# test the perl freetds dbi driver
#

use DBI ;

$user = '{dbuser}' ;
$passwd = '{dbpass}' ;


$dbh = DBI->connect('DBI:Sybase:server={servername}',
$user, $passwd);
$dbh->do("use {dbname}");

$action = $dbh->prepare("select count(*) from master..sysprocesses with (nolock)") ;
$action->execute ;
$rows = $action->rows ;
print "rows is $rows\n";

while ( @first = $action->fetchrow_array ) {
foreach $field ( @first ) {
print "$field\t";
}
print "\n";
}

exit(0);



No comments: