Edit

FOR XML support for the user-defined data types (UDT)

Applies to: SQL Server Azure SQL Database Azure SQL Managed Instance SQL database in Microsoft Fabric

FOR XML doesn't support common language runtime (CLR) user-defined data types (UDTs).

To use FOR XML with CLR user-defined data types, make sure that the data type has an XML serialization, and use an explicit cast to XML in the FOR XML select clause.