use DBI;
$DSN = "driver={SQL Server};server=;database=;uid=sa;pwd="; # sql connection string
$dbh = DBI -> connect ("DBI:ODBC:$DSN") # set driver
or die "could not connect to database";
$sth = $dbh -> prepare ("select * from SCHEMA_1.TB1") # initialize command line
or die "could not execute your sql command!";
$sth -> execute (); # execute
while (@data = $sth -> fetchrow_array ()) { # get data
print "id = $data[0] name = $data[1] \n";
}
$sth -> finish (); # finish this execution
$dbh -> disconnect (); # disconnect from database
perl 连接SQL SERVER 数据库
最新推荐文章于 2022-08-25 14:36:13 发布