Recently, when developing a file management system, I encountered another problem: the local database was originally sql2008, And the shareduserid field was nvarchar (max) type, I used the SQL query statement... where shareduserid + ',' like '% 2, %', can be executed normally. LaterProgramReleased to the purchased space server. The server is the SQL2000 database. Because SQL2000 does not have the nvarchar (max) type, it is changed to the text type, the program reports an error when executing the same SQL statement:
---------------------------
Microsoft Internet Explorer
---------------------------
The operator is invalid for data types. The operator is add and the type is text. (System. Exception)
---------------------------
OK
---------------------------
So I changed the field type of the local database to text, and then tested it. A similar error was reported (even sql2008 is in English ):
---------------------------
Microsoft Internet Explorer
---------------------------
The data types text and varchar are incompatible in the Add operator. (system. Exception)
---------------------------
OK
---------------------------
after searching online, the original query statement is slightly modified (convert text to nvarchar and then execute the + operation): ... where shareduserid + ',' like '% 2, %' to ... where cast (shareduserid as nvarchar) + ', 'like' % 2, %' or where convert (nvarchar, shareduserid) + ', 'like' % 2, % '