I'm having an SQL quoting problem, but not quite of the "normal" caliber.

I'm running ActiveState perl 5.6.0 on Windows 2000. I'm using DBD::ODBC to connect to an SQLServer 200 DB on the same host. The problem comes when I want to call a stored procedure and one of the arguments I want to pass to it contains a single quote. I've tried all the ways I know of to get around the escaping problem:

But whatever I do it doesn't seem to like the escaping of any single quotes in $bar:
DBD::ODBC::st execute failed: [Microsoft][ODBC SQL Server Driver][SQL +Server]Line 1: Incorrect syntax near 's'. (SQL-37000) [Microsoft][ODBC SQL Server Driver][SQL Server]Unclosed quotation mark + before the character string '.... (SQL-37000)(DBD: st_execute/SQLExe +cute err=-1) at testdiff.pl line 113.
I believe this to be an MS/SQLServer problem, not a DBD::ODBC problem (but I could be wrong). I'm hopeing that someone here will have a good workaround that can get me running.

Thanks, Les


In reply to SQL quoting problem by lhoward

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.