[unixODBC-dev] Long strings handling for MS SQL

Maciej Jaros egil at wp.pl
Thu Apr 14 22:16:59 BST 2011


Hi.

I'm using using PHP 5.2 with unixODBC driver to connect to MS SQL. The 
problem is that string length gets truncated to 255 characters and 
setting odbc.defaultlrl to 4096 doesn't work. This doesn't seem to be a 
PHP problem as this works fine in PHP+Windows.

The problem is probably that MS SQL can have more then 255 characters 
for varchar type.

A workaround for this is to map long varchar fields to text. And so this 
won't work:
SELECT myLongStr FROM myTable
But this works fine:
SELECT CAST(myLongStr as TEXT) as myLongStr FROM myTable

Where myLongStr definition is e.g.:
myLongStr varchar (7000)

Regards,
Nux.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.unixodbc.org/pipermail/unixodbc-dev/attachments/20110414/5133d3f9/attachment.html>


More information about the unixODBC-dev mailing list