shanthiann has asked for the wisdom of the Perl Monks concerning the following question:

hi perl monks, I tried to connect SQL server through DBI.pm .
But iam unable to connect ,which module support to connect to Sql Server
Regards,
Shanthi
  • Comment on which module support to connect SQLServer

Replies are listed 'Best First'.
Re: which module support to connect SQLServer - use DBD::ODBC with iodbc and freetds
by imp (Priest) on Oct 27, 2006 at 15:47 UTC
    I recommend using DBD::ODBC with iodbc and freetds.

    Note that freetds has to be compiled for iodbc, and DBD::ODBC does as well. Here is the install sequence I used recently:

    # Install libiodbc wget http://www.iodbc.org/downloads/iODBC/libiodbc-3.52.3.tar.gz && tar -xzf libiodbc-3.52.3.tar.gz && cd libiodbc-3.52.3 && ./configure && make && make install # Install freetds wget ftp://ftp.ibiblio.org/pub/Linux/ALPHA/freetds/stable/freetds-stab +le.tgz tar -xzf freetds-stable.tgz && cd freetds-0.63 && ./configure -with-iodbc && make && make install # Configure odbc.ini echo "[pcas2006] Database=pcas2006 Server=10.10.10.164 TDS_Version=8.0 Port=1433 Driver=/usr/local/lib/libtdsodbc.so" > /etc/odbc.ini # install DBD::ODBC perl -MCPAN -e'get DBD::ODBC' && cd ~/.cpan/build/DBD-ODBC-1.13 && export ODBCHOME=/usr/local && perl Makefile.PL && make && make install
    Update I should note that this advice is only applicable when connecting from a non-microsoft OS. If connecting from windows you can use DBD::ODBC without freetds and iodbc.
Re: which module support to connect SQLServer
by davorg (Chancellor) on Oct 27, 2006 at 15:45 UTC

    Which DBD module were you using with DBI? Can you show us your connection code? What connection errors are you getting?

    Assuming that by "SQL server" you meant Microsoft SQL Server, have you looked at DBD::ODBC?

    --
    <http://dave.org.uk>

    "The first rule of Perl club is you do not talk about Perl club."
    -- Chip Salzenberg

Re: which module support to connect SQLServer
by ptum (Priest) on Oct 27, 2006 at 16:01 UTC

    Connecting to SQLServer from a Unix environment is non-trivial, if you don't have an ODBC engine. The way some people (like me, on a Solaris platform) do it is to use FreeTDS and pretend it is a Sybase database (I guess SQLServer is still sort of Sybase-like under the covers) using DBD::Sybase. Anyway, Super Search is your friend -- there are several good nodes on this topic.

    Accessing Microsoft SQL Server from Linux using DBD::Sybase is probably a good place to start.

Re: which module support to connect SQLServer
by ww (Archbishop) on Oct 27, 2006 at 15:47 UTC
    shanlthiann
    you may wish to search CPAN for (at least 1350) answers to questions such as this... or if operating in a windows environment, using ActiveState, try ppm