Win32::SqlServer 2.008

Brief Overview

Win32::SqlServer is a module that permits you to access SQL Server from Perl, by using any of the OLE DB providers SQLOLEDB or SQL Server Native Client. Win32::SqlServer exposes two levels of interface, a high-level interface and a mid-level interface. The high-level interface is a developed version of the interface of my older module MSSQL::Sqllib, and largely backwards compatible with this interface. The mid-level interface exposes a few more knobs at the price of somewhat more verbose code. A special feature of Win32::SqlServer is the fine-grained control of error handling.

There is no support for DBI. This module does not run on Unix – or any other non-Windows OS for that matter.

What's in This Kit

This is the source-only distribution for CPAN, and do not include any binaries for Win32::SqlServer. If you want a binary distribution (for x86 or AMD64) please visit


To run Win32::SqlServer you need:

For details, see the Prerequisites section in the Win32::SqlServer manual.

Prerequisites for building, see below under Building from Sources.



The manual is in Win32-SqlServer.html. There is a POD file as well, but there is no real contents in it, only a pointer to the HTML file.

Reporting Bugs or Problems

Please mail bug reports and suggestions to Try to make your reports as specific as possible. Particularly do not forget to include which versions of Perl, Windows, SQL Server etc you are using.

I usually try to respond within 24-48 hours, but if I am on holiday I am.

Building from Sources


To build Win32::SqlServer you need:

How to Build and Install

Text in this type face indicates command you run from the command prompt.

  1. Extract the zip file anywhere you like.
  2. Edit so that $SQLDIR points to where sqlncli.h is located.
  3. If you use a different compiler from Visual C++, you need to review more closely as may include options that are specific to Visual C++.
  4. Note that explicitly lists which libraries to link with, and specifies the MT flag for the C compiler. This is to force use of the static C run-time library for Visual C++, which is what I want for the binary distribution. Change this if you like.
  5. Open a Command Prompt, and change directory to where you extracted the files.
  6. Perl
  7. MAKE
    Or NMAKE, DMAKE or whatever your MAKE utility you use.
  8. MAKE test
    Before you run the tests, please read tests.html so that you understand what impact the test scripts have on your server. This document also describes how to set the environment variable OLLEDBTEST, from which the test scripts get information how to log into SQL Server.
  9. MAKE install

Known Issues


Win32::SqlServer does not build for x86 with ActivePerl builds 1004 and 1005, because of a bug in ExtUtils::MM_Win32. I've reported the bug, and it was closed as fixed well before build 1005 came out, but 1005 does not include the fix. To build Win32::SqlServer for x86 with ActivePerl, you need build 1002 or build 1007 or later. (Maybe builds 1003 and 1006 are OK too, I have not tested those builds.)

The bug does not affect building Win32::SqlServer for the x64 architecture.

Other Compilers than Visual C++

To be honest, I have no idea if that will work. I have certainly not tested, and nor do I plan to. This includes other Perl distriutions, such as Strawberry Perl.

Last updated 12-09-23 23:02