

The DBD::ODBC module that is included in the ActivePerl distribution is statically linked against the iODBC driver manager.(If you have symbolically linked /usr/bin/perl to /opt/ActivePerl- version/bin/perl, this change will not be necessary.) Note that you will need to change /usr/bin/perl to /opt/ActivePerl- version/bin/perl in the !# entry at the start of the examples. For example:įor more Perl SQL Server examples, see Connecting Perl on UNIX or Linux to Microsoft SQL Server - Perl DBI/DBD::ODBC Tutorial Part 3.
#Active perl code#
#Active perl install#
#Active perl download#
The ODBC-ODBC Bridge is an alternative SQL Server solution from Easysoft, which you can download from this site. If the SQL Server ODBC driver is not currently available for your platform, check the list of ODBC-ODBC Bridge Client platforms. Download the SQL Server ODBC driver for your ActivePerl client platform.Copy the distribution file to your Perl machine, unpack and cd into the directory created by unpacking the file.Download the ActivePerl distribution from the ActiveState web site.


We tested the SQL Server ODBC driver with ActivePerl 5.10 on Debian GNU/Linux. The examples in this article will also work with earlier (7.0) and later (2008, 2012, 2014, 2016, 20) versions of SQL Server. We accessed SQL Server 2000, 2005 and Express databases from ActivePerl on UNIX and Linux. Print "$sth-> # Disconnect the database from the database handle. $sth ->execute () # Print the column name. my $sth = $dbh ->prepare ( $sql ) or die "Can't prepare statement: $DBI::errstr" # Execute the statement. my $sql = "SELECT 1 AS test_col" # Prepare the statement. my $dbh = DBI ->connect ( $data_source, $user, $password ) or die "Can't connect to $data_source: $DBI::errstr" # This query generates a result set with one record in it. my $data_source = q/dbi:ODBC:datasource_name/ my $user = q/database_username/ my $password = q/database_password/ # Connect to the data source and get a handle for that connection. # Replace database_username and database_password # with the SQL Server database username and password. #!/opt/ActivePerl-5.10/bin/perl -w # Example: Connecting ActivePerl on UNIX and Linux to MSSQL # use strict use DBI # Replace datasource_name with the name of your data source. The SQL Server ODBC driver is available for 32-bit and 64-bit Linux (CentOS, Debian GNU/Linux, Fedora, Mandrake/Mandriva, OpenSUSE/SUSE, RedHat, RedHat Enterprise Linux (RHEL) and Slackware) and UNIX (AIX, HP-UX and Solaris) platforms. Use the SQL Server ODBC driver to connect ActiveState ActivePerl to Microsoft SQL Server 7.0, 2000, 2005, 2008, 2012, 2014, 2016, 2017, 2019 and Express.
