The nvarchar field length is truncated to 255 when PHP connects to MSSQL. mssqlnvarchar_PHP tutorial

Source: Internet
Author: User
When PHP connects to MSSQL, the nvarchar field length is truncated to 255. When PHP connects to MSSQL, the nvarchar field length is truncated to 255. mssqlnvarchar this article describes how to cut the nvarchar field length to 255 when PHP connects to MSSQL. Solution: The nvarchar field length is truncated to 255 when you connect MSSQL to PHP, mssqlnvarchar

This example describes how to remove the nvarchar field length from the MSSQL connection in PHP to 255. Share it with you for your reference. The specific analysis is as follows:

New users who use PHP to connect to MSSQL often encounter this problem: all the data in the nvarchar field in the database is normal, but it is found that the length of the nvarchar field is only 255, and we all know that, in MySQL, the varchar length is only 255, but MSSQL is not. PHP will not process nvarchar according to MySQL's varchar.

The solution is as follows:

The code is as follows:

Select cast (Target Field as text) from table name

If the summary field in your article table is nvarchar, run the following command:

The code is as follows:

Select cast (summary as text) from article

The code for cast is as follows:

The code is as follows:

CAST (expression AS data_type)

Expression is the Target Field

Data_type is the data type to be converted

I hope this article will help you with php programming.

Examples in this article describes how the nvarchar field length is truncated to 255 when PHP is connected to MSSQL. Share...

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.