www.fromthevalley.com.au

MSSQL Driver

The DBD::Sybase module need access to a Sybase server to run the tests.
To clear an entry please enter 'undef'
Sybase server to use (default: SYBASE): MyServer  ----WHAT YOU CALL LOCALLY WITHIN PERL

User ID to log in to Sybase (default: sa): danielp  --SQL USERNAME
Password (default: undef):                                 -- SQL PASSWORD
Sybase database to use on MyServer (default: undef): MAS  --MSSQL DATABASE

 

 

 

 

Accessing Microsoft SQL Server from Perl

Note: From now on I will refer to Microsoft SQL Server as SQL Server.  Please do not confuse this with a generic sql server.  We can all now pause to gripe about the lack of imagination in product naming at Microsoft.

Compiling Freetds

Download and compile freetds from http://www.freetds.org/.

once you unzip and untar it, enter the directory and run:

./configure --prefix=/usr/local/freetds --with-tdsver=7.0
make
make install

Configuring Freetds

Now we have the freetds compiled, but we still have configure it.  This is the part that threw me off and is so different from other DBD drivers.  The DBD::Sybase driver will ultimately be affected by the contents of the /usr/local/freetds/etc/freetds.conf file.  If that file is not configured correctly, your DBD::Sybase connection will fail.

Okay, now that we have established there is a  relationship between the freetds.conf file and the DBD::Sybase module, let's edit the freetds.conf file.

The strategic modifications I made to the freetds.conf file were:

1) uncomment the following lines and modify if necessary:

try server login = yes
try domain login = no

Note: this forces the module to attempt a database login instead of a domain login.  I could not get domain login to work, though I will admit I did not try very hard.

2) uncomment the following line and modify if necessary:

tds version = 7.0

This supposedly sets the default tds version to establish a connection with.  I have only SQL Server 2000 servers, and they won't talk at any lower version.  So I set it to 7.0.  If for some reason you had older SQL Servers, you might leave it at the default 4.2.

3) create a server entry for my server sql1:

[sql1]

				host = sql1
	port = 1433
	tds version = 8.0
	
	

Note: My server here is sql1.  Ping sql1 worked, so I am sure I can resolve it using DNS.  You can also specifcy an ip address instead of the host name.  The sql1 in the brackets is just a descriptor.  It could be 'superduperserver' and it would still work as long as my 'host =' is set correctly.  I tried 'tds version 7.0' for my SQL Sever 2000 and it worked.  Version 5.0 though resulted in an error.  You might want to verify your SQL Server is listening on port 1433 with a 'netstat -a -n' run from the command line on the SQL Server.

At this point you can verify your configuration.

/usr/local/freetds/bin/tsql -S sql1 -U sqluser

You will then be prompted for a password and if everything is well, you will see a '1)' waiting for you to enter a command.  If you can't get the 1) using tsql, I doubt your DBD::Sybase perl code is going to work.  Please note that sqluser is not an Active Directory/Windows Domain user, but an SQL Server user.

Compiling DBD::Sybase

Now that we have the freetds library prerequisite for DBD::Sybase installed and configured, we can compile the DBD::Sybase perl module.  Obtain it from www.cpan.org if you haven't already.

once you have untarred it and are in the directory, run:

export SYBASE=/usr/local/freetds
perl Makefile.PL
make
make install

Note: The export line is to let the compilation process know where to find the freetds libraries.

 

THE MOST IMPORTANT PART OF THE WHOLE PROCESS IS ABOVE.
When you run perl Makefile.PL, you need to enter in parameters for the MSSQL server such as server(This refers to Local Server, ie what you will call it inside your $dbh->connect() method. It also binds you to one database on the SQL Server, ie ENTER A DEFAULT DATABASE NAME that you will be connecting to.

 

 

 

 

IF THE MAKE/MAKE INSTALL DOESN'T WORK, 

Then change to the extracted directory of DBD-Sybase.
There you need to patch the file "dbdimp.c" (vi dbdimp.c). Search there for the syntax "syb_init". Add some lines before the function:

 

Source code

						1
			2
			3
			4
			5
			
						#undef CS_VERSION_150
			#undef CS_VERSION_125
			#undef CS_VERSION_120
			#undef CS_DATE_TYPE 
			#undef CS_BIGINT_TYPE
			

 

  

10.0.0.9-I have had potential issues with using Sybase driver 1.07, and have successfully installed it using 1.08

10.0.0.14 - installed freetds 0.82 and DBD::Sybase 1.09

 DT

HOMEAJAXAPACHEBizphoneCSSDNSGeneralGraphicsHTMLHardwareJavascriptLinuxMACMS SQLMailMicrosoftOFFICE 365PerlPostgresSEOSocial MediaVMwareWindows 10