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

Anyone know where I can find a good tutorial on using Perl with MS SQL? I've scoured most of the resource sites but I can't seem to find anything on MS SQL, which is what my employer insists on using. I'm experienced with DBI and MySQL but I've never ventured past that. Any help would be appreciated.

Replies are listed 'Best First'.
Re: Perl/MS SQL tutorial?
by coreolyn (Parson) on Dec 29, 2000 at 02:31 UTC
Re: Perl/MS SQL tutorial?
by toadi (Chaplain) on Dec 29, 2000 at 02:55 UTC
    lol,

    If you are experienced with dbi you should know how to do it. Only the connecting string is a bit different. For the rest you can use almost the same syntax as before.

    To know the how the connect string should be build. Read the appropiate DBI module doc's.

    If you still have a problem with it. You can ask me, łaybe I can help cos I have experience with ms SQL and DBI. But ssssh don't tell anyone :)

    My opinions may have changed,
    but not the fact that I am right

Re: Perl/MS SQL tutorial?
by Lexicon (Chaplain) on Dec 29, 2000 at 05:41 UTC
    One would think that the DBI would be wonderful and work magick. I know a couple people who've tried to interconnect the two however, and since the moons weren't aligned it absolutly would not work.

    For me, it worked so poorly that that particular script is just using a text-file database. It didn't really need a database anyway, the boss just thought it would be slick to hook it up to one probably.

Re: Perl/MS SQL tutorial?
by little (Curate) on Dec 29, 2000 at 17:57 UTC
    Dear Anonymous,

    I have to agree on all what was said above.
    It seems that MS itself wants to ignore perl in sepcial - but you might study their ressources about ODBC and ASP.
    But currently this google search brought up plenty of related questions - I'm sorry - as I guess you will have to read through.
    At least - when you keep to standard sql you won't face any strange trouble with the MS SQl server itself.
    And I do also highly recommend reading "Programming the Perl DBI" as it covers most of the things you will need.

    Have a nice day
    All decision is left to your taste
      I don't understand. How did it mess up?
      I've been using DBI with MS SQL Server 7 here for months now, with little in the way of headaches. Hooking up to the server, retriving/editing, etc. all work fine. The only serious problem I can think of involved Memo/OLE Object files, and that's well-documented in the DBD::ODBC docs.
      ----Asim, known to some as Woodrow.
Re: Perl/MS SQL tutorial?
by InfiniteSilence (Curate) on Dec 29, 2000 at 19:40 UTC
    If you are not doing anything too powerful (seeing as how you used a flat text file, I gather you are not) and you are using the ActiveState build of Perl, you can use the Win32::OLE module with a DSN like in the following:

    #!/usr/local/bin/perl -w use strict; =head Win32::OLE using a System DSN called testconn Objectives: Read stuff from an MSAccess database to prove that thi +s works Error handling tests =cut use OLE; my $Conn = CreateObject OLE "ADODB.Connection"; $Conn->Open("DSN=testconn"); my $RS = $Conn->Execute("Select * from Customers"); if (!$RS) { my $Errors = $Conn->Errors(); my $error; foreach $error (keys %$Errors) { print $error->{Description}, "\n"; } } while(!$RS->EOF) { print $RS->Fields('CustomerID')->value, "\n", $RS->Fields(2)->value,"\ +n"; $RS->movenext(); } 1;

    I suppose you can look around for more information on Win32::OLE on the web. The perldoc includes more examples on how to access Microsoft Excel.

    Celebrate Intellectual Diversity