Our Blog

Related Posts

How to achieve Pantheon's one-click-update functionality for Drupal and Wordpress while retaining your git history using git-graft.

Creative Director Maya Brueck recounts Pixo's recent project management shift away from the Waterfall model to a more collaborative workflow.

Troubleshooting an issue with the default MSSQL PHP driver: smalldatetime bug causing silent process termination.

Popular Tags

Recent Comments

Brendon Carvalho
4.26.2018 - MSSQL Long Text Field Truncated In PHP
Hire Volusion Developers
4.7.2018 - Drupal 8 Roadmap

Cameron Macintosh

In addition to the SmallDateTime bug outlined in a previous post, I also encountered this troublesome bug involving truncated SQL data because of a MSSQL nuance on lengthy VARCHAR fields.

The Lost Field of Text

There existed several string/text fields in the legacy MSSQL database defined with 1000-8000 character capacity. However initially I was only getting the first 255 characters.

MSSQL allows you to define VARCHAR fields greater than 255 characters, but there is a limitation in the driver that only allows the first 255 characters of a varchar to come through. As it turns out, one has to typecast the varchar field to a text field in order to get the full data:

select convert(text,longTextField) as longTextField
  from myTable where ID=100

Converting each string field (or at the very least, those I knew to be 256+ characters) seemed less than ideal to me. However, in this case practicality beats purity. I was already passing one giant array of fields into my query building function, and it was easy enough to add a second array to handle these over sized text fields. Problem solved!

Related Posts

How to achieve Pantheon's one-click-update functionality for Drupal and Wordpress while retaining your git history using git-graft.

Creative Director Maya Brueck recounts Pixo's recent project management shift away from the Waterfall model to a more collaborative workflow.

Troubleshooting an issue with the default MSSQL PHP driver: smalldatetime bug causing silent process termination.

Recent Comments

Brendon Carvalho
4.26.2018 - MSSQL Long Text Field Truncated In PHP
Hire Volusion Developers
4.7.2018 - Drupal 8 Roadmap

Interested in working with us?
CONTACT US