Wednesday, November 17

255 varchar limit

Again, I have to use an MSSql database with php. I was having a problem: I'd insert a large amount of text into a varchar(1000) field, but when I tried to display it, only 255 characters came out. The problem has something to do with the drivers linux uses for php to connect to MSSql. There were two ways to handle this.

If I didn't have access to the database, I can cast the data as a text.
SELECT CAST(details as TEXT) from table
But since I had access to the database, I just changed the datatype of that field to text. Now all 1000 (even up to 2^31-1) characters will display.

No comments: