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

Hi Monks ! I have a problem using DBD::Sybase to access a MSSQL 2000 database... I can't retrive more than 255 chars in varchar fields... Does anybody knows how to fetch more chars ? This isn't a MSSQL 2000 limitation, because I can fetch up to 16k chars using Java or C++. Somebody can bring me some lightening ?
  • Comment on MS SQL (DBD::SyBase) varchar limitation

Replies are listed 'Best First'.
Re: MS SQL (DBD::SyBase) varchar limitation
by Arunbear (Prior) on Apr 15, 2008 at 16:02 UTC
    Try setting the LongReadLen attribute to a suitably high value, e.g.
    $dbh->{LongReadLen} = 1000;
Re: MS SQL (DBD::SyBase) varchar limitation
by runrig (Abbot) on Apr 15, 2008 at 18:09 UTC
    The documentation seems to indicate that 255 is all you'll get. Try converting the column to text: select CAST(my_varchar_column as TEXT) ..., (or try DBD::ODBC).
      Didn't work :( I tried DBD::ODBC and didn't work too...
        Define "didn't work". Same truncation at 255 characters, or something else?
Re: MS SQL (DBD::SyBase) varchar limitation
by mpeppler (Vicar) on Apr 16, 2008 at 06:35 UTC
    The 255 char limitation is a protocol level limitation. You need to make sure that you connect to your MS-SQL server with TDS 8 (you set this in the freetds.conf file, IIRC).

    Once that is done then you should be able to retrieve varchar columns wider than 255 (or at least there is no limit in DBD::Sybase that would prevent that.)

    As an aside, LongReadLen has nothing to do with this - that's for BLOB-type columns (in Sybase/MS-SQL parlance that's TEXT and IMAGE data).

    Michael

    PS: keep in mind that I don't use FreeTDS, or MS-SQL at all, so the above is pretty much all I know about the matter...