nvarchar field length truncated to 255 when PHP connects to MSSQL _php tips

Source: Internet
Author: User
Tags mssql truncated

The example in this article describes a workaround where the nvarchar field length is truncated to 255 when PHP connects to MSSQL. Share to everyone for your reference. The specific analysis is as follows:

PHP connected to the novice of MSSQL often encounter this problem: the database inside the nvarchar field data all normal, but with PHP query out but found that length is only 255, we all know, in MySQL inside varchar length is only 255, but MSSQL is not , PHP will not be nvarchar according to MySQL varchar processing it.

This article gives the solution:

Copy Code code as follows:
Select CAST (Target field as text) from table name

If you have a field in your Article table summary as nvarchar, then the command is:

Copy Code code as follows:
Select CAST (summary as text) from article

For cast, the code is as follows:

Copy Code code as follows:
CAST (expression as data_type)

Expression as Target Field

Data_type is the type of data to convert to

I hope this article will help you with your PHP program design.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.