ERROR MESAGGE:
“Argument data type xml is invalid for argument 1 of like function”
EXPLANATION:
You may encounter an error when you query an XML field using the LIKE operator.
SOLUTION:
For example, suppose you have a table named “Books” with fields such as “CategoryID INT”, “PublishingHouse NVARCHAR (70)”, “Book XML”.
You will encounter this error if you run a query in this table as follows:
1 | SELECT CategoryID,PublishingHouse FROM Books WHERE Book LIKE '%dbtut%' |
Because you cannot directly query the XML column with the LIKE operator.
To run the query without error, you can convert the XML column to NVARCHAR:
1 | SELECT CategoryID, PublishingHouse FROM Books WHERE (CAST(Book AS NVARCHAR(MAX)) LIKE '%dbtut%' |