Wednesday, 11 September 2013

How to change FOR XML PATH to run in SQL 2000

How to change FOR XML PATH to run in SQL 2000

Please provide updated code example based on my code that would execute in
SQL 2000. I'm aware that FOR XML PATH does not work in SQL 2000.
Here is my code:
SELECT @group_ids = STUFF(( SELECT DISTINCT '],[' + LTRIM(groupid)
FROM #DistinctPages
ORDER BY '],[' + LTRIM(groupid)
FOR XML PATH('')
), 1,2, '') + ']'
--set details of report to -- if the value is null
SELECT @colsNull = STUFF((SELECT ', coalesce(' + QUOTENAME(groupid) +',
''--'') as '+QUOTENAME(groupid)
FROM #DistinctPages
GROUP BY groupid
ORDER BY groupid
FOR XML PATH(''), TYPE ).value('.', 'NVARCHAR(MAX)') ,1,1,'')

No comments:

Post a Comment