If you’re running a subquery that uses FOR XML
to produce XML in SQL Server, but you’re getting error 258, which reads “Cannot call methods on nvarchar(max)” it might be that you’re trying to query the XML in the outer query, but your inner query isn’t outputting the XML as an actual xml type.
The FOR XML
result must be an xml type in order to process the result on the server.
To fix this issue, make sure the subquery outputs the result using the xml data type.
Continue reading