Quantcast
Channel: SQLServerCentral » SQL Server 2012 » SQL Server 2012 - T-SQL » Latest topics
Viewing all articles
Browse latest Browse all 4901

Aliasing a FOR XML PATH result

$
0
0
Hi,I want to alias the output of the following:[code="sql"]-- Test table with some rubbish dataDECLARE @Test TABLE( Names [varchar](20))INSERT INTO @TestSELECT 'Simon'-- Query returns but with XML_<GUID> aliasSELECT NamesFROM @Test t FOR XML PATH ('Test')[/code]So rather than a column header of XML_<GUID> I want to give it an alias of say 'Test' for sake of argument. I can't seem to get it. Anyone know how? I tried following an example from here: [url=http://social.msdn.microsoft.com/Forums/nl/sqlxml/thread/1605c722-6388-40ff-9ab5-a3817a1db81f]http://social.msdn.microsoft.com/Forums/nl/sqlxml/thread/1605c722-6388-40ff-9ab5-a3817a1db81f[/url] but I can't seem to get it to return. I always run into the error that says the is no name for column 1.Any help appreciated.Thanks,Simon

Viewing all articles
Browse latest Browse all 4901

Trending Articles