This article mainly introduces the solution that the nvarchar field length is truncated to 255 when PHP is connected to MSSQL. it can be solved through CAST data type conversion and is a very practical technique, for more information about how to connect to MSSQL using PHP, see the example below. the nvarchar field length is truncated 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.