Win32::SqlServer 2.005
This is Win32::SqlServer, a module for calling Microsoft SQL Server from Perl
through OLE DB.
Copyright © 2004-2009 Erland Sommarskog.
All rights reserved.
This program is free software; you can redistribute it and/or modify it under
the same terms as Perl itself.
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 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 that you get fine-grained control for 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
The zip file includes x86 and AMD64 binaries for ActivePerl builds 820 and1002.
The binaries should work with other 8xx builds from 809 and up, and for later
10xx builds, as long as ActiveState does not introduce any incompatible changes.
The kit also includes source
code and test scripts. If you want to run this on Itanium, you will
either have to use the x86 binary, or try to build from sources. (Note that I in
lieu of hardware do not claim to support Itanium.) For information on how to build from sources, see below. The binaries were built on Windows
Vista with the Visual Studio 2008 C++ compiler and builds 820 and 1002 of ActivePerl.
Prerequisites
- Perl 5.8.3 or later. (That is ActivePerl build 809 or later.)
- Windows NT4 SP6, Windows 2000, Windows XP, Windows 2003, Windows Vista and
Windows 2008.
- SQL Server 6.5 or later.
- MDAC 2.6 or SQL
Server Native Client.
For details, see the Prerequisites
section in the Win32::SqlServer manual.
Note that the binaries are not likely to run with other binary distributions of Perl for Win32, such
as Strawberry Perl.
How to Install the Binary
To test that the installation is OK, either run any of the test scripts that
comes with Win32::SqlServer and which are detailed in tests.html,
or run any of the sample scripts
in the manual.
Manual
The manual is in Win32-SqlServer.html.
activeperl-copy.pl also installs it as html/site/lib/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
esquel@sommarskog.se. 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.
Prerequisites
To build Win32::SqlServer you need:
- The Platform SDK for Windows, more
precisely, the Core SDK and the MDAC SDK.
The Platform SDK comes with Visual Studio. You can
also download the
Windows SDK for Windows Server 2008 and .NET Framework 3.5.
(The link is the current as of this writing. Microsoft often twitches things
around, so you have to search for it.)
- The SDK (header files and link libraries) for SQL Server Native client that comes with SQL 2008. (The SDK for SQL
2005 won't do.)
- Perl 5.8.3 or later.
-
A C++ compiler, preferably Visual C++ 8.0 or later. (The C++ compiler that
comes with Visual Studio 6 will not work.) If you don't have
Visual Studio, the Windows SDK (see above), comes with one.
- A make facility. Microsoft's NMAKE also
comes with the Windows SDK.
Note that if you build Win32::SqlServer for another binary distribution of Per than ActivePerll, you should use the
C compiler and MAKE facility that distribution was built with. For instance, if you have Strawberry Perl you should use DMAKE
and GNU-C. If you try to use NMAKE, you will get strange error messages due to that DMAKE requires special tweaks to the
syntax of Perl code embedded into the Makefile.
How to Build and Install
Text in this type face indicates command you run from the command
prompt.
- Extract the zip file anywhere you like.
- Edit makefile.pl so that
$SQLDIR points to where sqlncli.h is
located.
- If you use a different compiler from Visual C++, you need to review
makefile.pl more closely. makefile.pl includes two linker options
specifed with dynamic_lib option that are likely to work only with Visual C++.
/base is only there to set a difference base address for better startup
performance. /delayload is more important: it defers the loading of
sqlncli10.dll until it's actually needed, or more precisely until you call
OpenSqlFilestream. Without /delayload, Win32::SqlServer would not run on systems
without SQL Server Native Client 10. If you use a different compiler than VC++,
this is something you need to address.
- Note that makefile.pl 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.
- Open a Command Prompt, and change directory to where you extracted the
files.
- Perl makefile.pl.
- MAKE
Or NMAKE, DMAKE or whatever your
MAKE utility you use.
- 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.
- MAKE install
Known Issues
ActivePerl
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. (Maybe build 1003, I have not tested that build.)
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.
Last updated 09-06-21 19:45