BenEskew.com Just another web developer's personal weblog.

Recommended Hosting
23Aug/100

The MS SQL and NTEXT Problem (SOLVED)

So, the other day I ran into the problem of trying to pull data from a field which was of type ntext in a MS SQL database using PHP. I'm fairly new with MS SQL and Windows IIS server environments for that matter so please bare with me. Well, I found the solution!

When you're using PHP's mssql_ functions and you need to pull data from a table field which is of type ntext you can't simply pull it using typical select methods, you need to cast the variable as another because the ntext type is not supported in PHP's mssql_ functions.

Code Which Wasn't Working:
$r = mssql_query("select ProductID, Description from myTable where id = '1'");

Solution:
$r = mssql_query("select ProductID, CAST(Description AS TEXT) AS Description from myTable where id = '1'");

Comments (0) Trackbacks (0)

No comments yet.


Leave a comment

You must be logged in to post a comment.

No trackbacks yet.