invalid XML identifier as required by FOR XML

 The weirdest error I got today was this : 

  •  Column name 'DATA()' contains an invalid XML identifier as required by FOR XML; '('(0x0028) is the first character at fault.

This was happening when I was trying to concatenate rows from a column into a single row like this :

   1:  
   2: REPLACE(
   4: (
   6: SELECT [Name] as [DATA()]
   7:   
   8:   FROM ContactPerson 
   9:  
  10:    WHERE ClientId = dbo.Client.ClientId
  12:    
  13: FOR XML PATH ('') ), ' ', ',') as AllPersonsNames

 I eventually found on a web site the answer : it shouldn't be DATA() it should be data() Surprised

Tags: ,

Comments are closed