Prova quanto segue: Declare @xmldata xml set @xmldata = (select ... From test for xml...) select @xmldata as returnXml