Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Connecting to MS SQL server from Linux / Unix

by allyc (Scribe)
on Jan 21, 2003 at 22:30 UTC ( #228871=perlquestion: print w/replies, xml ) Need Help??
allyc has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,

Could any one help me with this Perl problem that I am having. I need to be able to query, and most importantly insert rows into a table that is hosted on a MS SQL Server on a NT Box.

I have now tried DBI:Sybase, but I cant get it to work properly on my Linux Box. The biggest problem I have is that I need this to work on a Suse Linux box and a HP- UX Unix box and I will struggle to get things installed on the HP64 box!

Would any one have any suggestions that would point me in the right direction because I would be very grateful!



  • Comment on Connecting to MS SQL server from Linux / Unix

Replies are listed 'Best First'.
Re: Connecting to MS SQL server from Linux / Unix
by impossiblerobot (Deacon) on Jan 21, 2003 at 23:23 UTC

    You didn't mention what TDS driver you are trying to use, but I've used FreeTDS successfully with DBD::Sybase. There are some links to FAQs on setting up FreeTDS for use with the Perl DBI, as well as how to set up your FreeTDS configuration for use with MS SQL Server, at

    And here's an example from this site using DBD::ODBC, if you decide to go that route.

    Update: Here's a link to some more useful information.

    Impossible Robot
Re: Connecting to MS SQL server from Linux / Unix
by LD2 (Curate) on Jan 22, 2003 at 01:21 UTC
Re: Connecting to MS SQL server from Linux / Unix
by jplindstrom (Monsignor) on Jan 21, 2003 at 23:12 UTC
Re: Connecting to MS SQL server from Linux / Unix
by mpeppler (Vicar) on Jan 21, 2003 at 23:25 UTC
    Are you using FreeTDS?

    If so, you are likely getting a run-time error with a missing cs_ctx_global symbol missing. The fix is to either get the latest CVS snapshot for FreeTDS, or to edit DBD::Sybase's dbdimp.c file and change any occurance of cs_ctx_global to cs_ctx_alloc and rebuild DBD::Sybase.


Re: Connecting to MS SQL server from Linux / Unix
by Gilimanjaro (Hermit) on Jan 22, 2003 at 10:43 UTC
    We have done *exactly* what you need at our office, using the DBD::JDBC driver with DBI.

    DBD::JDBC will require you to have access to the Microsoft's JDBC drivers (which are freely available). You'll have to run a small java-executable that comes with DBD::JDBC on your Unix system which relays request from the Perl module to the jdbc driver.

    The only problem we had was that the java-executable sometimes just decided to die. Because we only needed access for a batch job, we decided have our perl script start and stop the executable and the respective beginning and end of the job...

    Nicest about this solution is you only use a plain perl module, and plain java and the MSSQL jdbc-jar, so you can easily do this on any platform without compiling a thing.

Re: Connecting to MS SQL server from Linux / Unix
by BazB (Priest) on Jan 21, 2003 at 22:57 UTC

    I've not got any experience connecting to MS SQL Server, however, might I suggest you look at DBD::ODBC?



    If the information in this post is inaccurate, or just plain wrong, don't just downvote - please post explaining what's wrong.
    That way everyone learns.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://228871]
Approved by BazB
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2018-06-19 14:54 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (114 votes). Check out past polls.