cgcmq
asked on
Using a variable in path name FOR XML PATH
Is it possible to use a variable that has been declared in the query for the path name in FOR XML PATH?
For example, I have a variable
@Section varchar(100)
How can I use this as the root name in XML PATH:
FOR XML PATH('Products'), ROOT(@Section)
I am using SQL Server 2005
For example, I have a variable
@Section varchar(100)
How can I use this as the root name in XML PATH:
FOR XML PATH('Products'), ROOT(@Section)
I am using SQL Server 2005
ASKER
None of those links addressed the issue of using a variable as the name of a node in XML PATH. I suspect that it may simply be a matter of the correct syntax within a stored procedure to replace
FOR XML PATH('Products'), ROOT('name of this node')
with:
FOR XML PATH('Products'), ROOT(@Section)
FOR XML PATH('Products'), ROOT('name of this node')
with:
FOR XML PATH('Products'), ROOT(@Section)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Sorry for the delay - I was out of town for several days.
http://searchsqlserver.techtarget.com/tip/0,289483,sid87_gci1309059,00.html
also
http://www.sqlmag.com/Article/ArticleID/99197/sql_server_99197.html
http://www.yukonxml.com/Daily/default.aspx?pgNo=9
http://www.sswug.org/searchresults.asp?keywordstofind=path