#/usr/bin/perl -w use strict; use DBI; my $DSN = 'dbi:ODBC:driver={SQL Server};server={myserver};database={mydb}'; my $dbh = DBI->connect($DSN, undef, undef) or die "$DBI::errstr\n"; my $gSQLCmd = 'SELECT col1, col2, col3 FROM mytable'; my $gSQLHandle = $dbh->prepare ( $gSQLCmd ) || die 'Error with SQL statement ['.$DBI::errstr.' - '.$DBI::err.']'; $gSQLHandle->execute() || die 'Error with SQL statement ['.$DBI::errstr.' - '.$DBI::err.']'; while (my @gFields = $gSQLHandle->fetchrow_array) { print 'Row: ',$gFields[0],"\t",$gFields[1],"\t",$gFields[2],"\n"; } $dbh->disconnect;