I want to save the output for the XML Path in a variable. However, this does not work:
Declare @Tab dbo.SingleColumnTable
Insert INTO @Tab
Values(
'Jack'
)
Insert INTO @Tab
Values(
'Armageddon'
)
Declare @RetVal varchar(8000) = ''
Select Top 1 @RetVal = Data
From
(
Select ';' + ' ' + Name as 'Data'
From @Tab t2
for xml path('')
) v
As you can see, I am trying to set the column name of the returned output as Data, but it does not work. I get an errorInvalid column name 'Data'.
source
share