SQL Server - contains an invalid XML identifier in accordance with FOR XML requirements;

I execute this request and get the error mentioned below. Can anyone help?

The middle name column name contains an invalid XML identifier, as required for XML; '' (0x0020) is the first sign of an error.

SELECT Username as [LastName], '' AS [Middle Name], '' AS Birthdate, '' AS [SSN], 0 AS [Wage Amount] FROM Employee FOR XML PATH 
+5
source share
1 answer

You cannot have spaces in the XML element or attribute names. Use

 SELECT Username AS [LastName], '' AS [MiddleName], '' AS Birthdate, '' AS [SSN], 0 AS [WageAmount] FROM Employee FOR XML PATH 
+10
source

All Articles