Previously, when writing query statements habitually, the query condition was judged by "=". When writing a program today, the query suddenly reported an error: Data type text and varchar are incompatible in the equal to operator. Looking at the database discovery, where a property (for example, name:) is of type text, then the query condition Name= ' Zhang San ' will give an error. Find related data A property of the text type cannot be judged equal with "=" because it is not supported and can be judged with "like", for example: Name "Zhang San".
There are a few additional points to note:
(1): The text field type cannot be replaced directly with the Replace function, and must be UPDATETEXT
(2): Field comparison cannot use the where field = ' Some data ', you can use like to replace
(3): UPDATETEXT, if the @ptrval value is empty will be an error, you need to note * *
Some people say that text is rarely used now, because in Ms SQL2005 and above, a large data type (varchar (max), nvarchar (max), varbinary (max)) is added. A large value data type can store up to 2^30-1 bytes of data.
These data types behave in the same way as the smaller data types varchar,nvarchar , and varbinary .
Microsoft's argument is that this data type is used instead of the previous text,ntext , and image data types, and the correspondence between them is:
varchar (max)-------text;
nvarchar (max)-----ntext;
varbinary (max)----image.
When a property of text type exists in a database table, you need to be careful when writing SQL statements!