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

Hey All,

I moved to a next level and require to write a script that connects to MsSQL DB. The script is run from a Linux box what makes it little bit tricky. What is the minimum that I need to put on the box to achieve it? Forums all over the internet suggest very different solutions and I do not have much room to test them. Before I use DBD::Sybase or DBD::ODBC what do I actually need to have installed on the box? Is is either of freeTDS or unixODBC or do I maybe need them both?

Any suggestions welcome.

Thanks in advance.

Wojtek
  • Comment on minimum for connecting to MsSQL from UNIX with perl

Replies are listed 'Best First'.
Re: minimum for connecting to MsSQL from UNIX with perl
by thewebsi (Scribe) on Oct 14, 2011 at 01:48 UTC

    I am successfully connected to an MS-SQL database with FreeTDS, unixODBC, and DBD::ODBC installed. They are all required: DBD::ODBC is the DBI driver interface layer, unixODBC provides the ODBC layer, and FreeTDS is the database driver. I believe you will also have to edit /etc/odbcinst.ini to recognize FreeTDS as a driver.

Re: minimum for connecting to MsSQL from UNIX with perl
by BrowserUk (Patriarch) on Oct 14, 2011 at 01:40 UTC

    Have you read DBD::ODBC::FAQ?

    In particular Where do I get an ODBC driver manager for Unix/Linux?.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
Re: minimum for connecting to MsSQL from UNIX with perl
by GrandFather (Saint) on Oct 14, 2011 at 00:16 UTC

    If you are connecting to a mysql database then you need DBD::mysql. The connect line looks like:

    use DBI; my $dbh = DBI->connect( 'dbi:mysql:dbname=MyDatabase;host=myhost.somewhere.someplace', 'MyUserName', 'MyPassword' );

    Update: Urg, misread 'ms' as 'my' - even with the strong OBDC etc. hints!

    True laziness is hard work