Skip to Content.
Sympa Menu

freetds - Re: [freetds] FreeTDS Digest, Vol 32, Issue 24

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Frode Nordahl <frode AT nordahl.net>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] FreeTDS Digest, Vol 32, Issue 24
  • Date: Sat, 1 Oct 2005 11:34:12 +0200

On 30. sep. 2005, at 22.43, V mar wrote:
can i get a small perl script to connect to sql server
database.

This script should be a good starting point.

Depending on what version of SQL Server you are trying to connect to, your freetds.conf should contain the following:
[TEST]
host = <IP ADDRESS OF SERVER>
port = 1433
tds version = 8.0

#!/usr/bin/perl

use strict;
use DBI;

my $DBDRIVER = 'Sybase';
my $DBSERVER = 'TEST';
my $DATABASE = 'test';
my $DBUSER = 'testuser';
my $DBPASS = 'tfdese';

my $dbh = DBI->connect("dbi:$DBDRIVER:server=$DBSERVER;database=$DATABASE",
                    $DBUSER, $DBPASS) || die ("Unable to connect to database");

my ($query, $q, @data) = ();

$query = "SELECT * FROM TEST";
$q->prepare($query);
$q->execute();

while (@data = $q->fetch) {
	print join(", ", @data) . "\n";
}
$q->finish();
$dbh->disconnect();

Frode Nordahl
frode AT nordahl.net





  • Re: [freetds] FreeTDS Digest, Vol 32, Issue 24, Frode Nordahl, 10/01/2005

Archive powered by MHonArc 2.6.24.

Top of Page