﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2012 / SQL Server 2012 -  T-SQL  / Aliasing a FOR XML PATH result / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Tue, 18 Jun 2013 18:08:13 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Aliasing a FOR XML PATH result</title><link>http://www.sqlservercentral.com/Forums/Topic1408346-3077-1.aspx</link><description>Worked an absolute treat! Thanks very much!!</description><pubDate>Thu, 17 Jan 2013 06:16:02 GMT</pubDate><dc:creator>s_osborne2</dc:creator></item><item><title>RE: Aliasing a FOR XML PATH result</title><link>http://www.sqlservercentral.com/Forums/Topic1408346-3077-1.aspx</link><description>This is the easiest way, though it may not work for what your actual query is but...[code="sql"]-- Test table with some rubbish dataDECLARE @Test TABLE(	Names [varchar](20))INSERT INTO @TestSELECT 'Simon'-- Query returns but with XML_&amp;lt;GUID&amp;gt; aliasSELECT (SELECT 	NamesFROM 	@Test t FOR XML PATH ('Test') ) as Test[/code]</description><pubDate>Thu, 17 Jan 2013 06:13:49 GMT</pubDate><dc:creator>Allen Kinsel</dc:creator></item><item><title>RE: Aliasing a FOR XML PATH result</title><link>http://www.sqlservercentral.com/Forums/Topic1408346-3077-1.aspx</link><description>[code="sql"]/* If you're using SQL2005+ you could try something this */;WITH  CTE ( Test )        AS ( SELECT  Names             FROM    @Test t             FOR     XML PATH('Test')           )   SELECT   Test ,            CAST(Test AS XML) AS Test   FROM     CTE[/code]</description><pubDate>Thu, 17 Jan 2013 06:07:50 GMT</pubDate><dc:creator>rob_dalzell</dc:creator></item><item><title>Aliasing a FOR XML PATH result</title><link>http://www.sqlservercentral.com/Forums/Topic1408346-3077-1.aspx</link><description>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_&amp;lt;GUID&amp;gt; aliasSELECT 	NamesFROM 	@Test t FOR XML PATH ('Test')[/code]So rather than a column header of XML_&amp;lt;GUID&amp;gt; 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</description><pubDate>Thu, 17 Jan 2013 05:03:57 GMT</pubDate><dc:creator>s_osborne2</dc:creator></item></channel></rss>