Format Table Variable Output with FOR XML AUTO
问题 Using SQL Server 2008. I have a table variable with a single column and single row. If I do this: Declare @testsToRun Table ( testsId BigInt ) Insert Into @testsToRun Select testsId From tests Where testsId = 10 Select Top 1 * From @testsToRun For Xml Auto , Type , Root('testMessage') I get XML that looks like this: <testMessage> <_x0040_testsToRun testsId="10" /> </testMessage> When what I actually want is: <testMessage> <testsToRun testsId="10" /> </testMessage> If the row source is a table