My DOTD: MS SQL vs. PHP: 4096 is the (default) limit

SQL ServerSmall tip: when getting data from a MS SQL Database through PHP you’ll notice that your data gets chopped. First thought that the datatypes of the fields weren’t sufficient enough to hold the data, but the text datatype can hold up to 2ˆ31 - 1 characters and the data was stored correctly in the database …

After a little investigation I found that the data got chopped at 4096 characters, which is a bit too familiar as it’s the outcome of 2ˆ12. Digging a bit deeper it turns out that the problem lies within php.ini as it defaults to only returning 4096 characters. The settings controlling these are mssql.textlimit and mssql.textsize.

Since 4096 is way too little, I’ve changed it to 1048576 (which is 2ˆ20) which should be more than enough.

; Valid range 0 - 2147483647.  Default = 4096.
mssql.textlimit = 1048576

; Valid range 0 - 2147483647.  Default = 4096.
mssql.textsize = 1048576

Hope this saves you some research and hassle 😉

Did this help you out? Like what you see?
Consider donating.

I don’t run ads on my blog nor do I do this for profit. A donation however would always put a smile on my face though. Thanks!

☕️ Buy me a Coffee ($3)

Published by Bramus!

Bramus is a frontend web developer from Belgium, working as a Chrome Developer Relations Engineer at Google. From the moment he discovered view-source at the age of 14 (way back in 1997), he fell in love with the web and has been tinkering with it ever since (more …)

Unless noted otherwise, the contents of this post are licensed under the Creative Commons Attribution 4.0 License and code samples are licensed under the MIT License

3 replies on “My DOTD: MS SQL vs. PHP: 4096 is the (default) limit”

Comments are closed.