Setup
I am using several memory tables to cache data for my website. This is a local web host on my mac and a dev server on linux using mssql php library on php 5.5
A simplified table looks like:
CacheID INT NOT NULL
CacheData VARCHAR(MAX)
I occasionally insert several large values. 10,000+ characters. The insert works fine. A simple query tells me all the data is in the field:
SELECT
CacheID,
LEN(CacheData)
FROM Caches
Problem
However, when I actually select the data the cache
column is always truncated to 8192 characters causing problems. Simple select:
SELECT
CacheData
FROM Caches
WHERE CacheID = 10
I checked varchar(max) character limit. And it is well beyond 8192. 2^32 - 1
The question
Why is the data being Truncated?
The question in another form. I actually ran into this agian and forgot about this solution. Took me a bit to remember as I forgot the root cause. Here is what I searched for thinking that SQL Server was the culprit.
What is SQL Servers Varchar(MAX) maximum length? - If your values are being truncated its probably caused by php non sql server. If you just want to know what the max is, the question is answered here: Maximum size of a varchar(max) variable