I have the following sql
SELECT
bw_imp_step as imp_action,
FROM cm3rm1 m1 INNER JOIN cm3rm2 m2 ON m1.number=m2.number
WHERE m1.number=\'$id\'
I know this is an old post, but I just ran into this too and the situation was sufficiently complex to warrant a complete answer.
There are several places where the your data could be getting truncated.
ODBC Long Read Length
ODBC has a default long read length (lrl) for large columns. Make sure the lrl for your fetch is sufficiently large, by doing one of the following:
Set the default in php.ini
to something bigger, like odbc.defaultlrl = 10000
.
Or use ini_set("odbc.defaultlrl", "10000");
to set it in your code before making your connection.
Or use odbc_longreadlen($result, "10000");
to set it in your code before fetching your result.
FreeTDS
If you're using FreeTDS to connect to an MS SQL DB from a Linux environment, there's a text size
limit set in your freetds.conf
file. Double check that your configuration is large enough here.
php_mssql
As in @Anujan's answer, some people (not the OP, I think) may be using php_mssql
to make their connection, in which case you want to make sure your mssql.textlimit
and mssql.textsize
are sufficiently large, either by settings them in your php.ini
or with the following in your code (before making your connection):
ini_set('mssql.textlimit', "10000");
ini_set('mssql.textsize', "10000");
SQL Server
The SQL Server itself sets a default text size and you may need to explicitly bump it up (especially if using ODBC without php_mssql
and the configuration given for it above). In this case, add the following to the beginning of your query string:
SET TEXTSIZE 10000
SELECT big_ol_column FROM wherever
...
Note that some changes (like to php.ini
) may require you to reload/restart PHP/Nginx/Apache to take effect.
You should be able to figure out which of these is capping your result by looking at your truncated result size. For me, everything kept coming back 4096 characters long, so I new whatever was capping me was set to that.
Also note that "10000" in the example above is not a magic number—adjust it to suit your needs.