May 21, 2014 at 7:56 am
While working on a forum posting on this site, I came up with this code:
WITH JoinedTables(UserGroup, UserName) as (
SELECT 'UG1', 'Tom' UNION All
SELECT 'UG1', 'Harry' UNION all
SELECT 'UG2', 'Albert' UNION all
SELECT 'UG3', 'Jim' UNION all
SELECT 'UG3', 'Sam'
)
SELECT UserGroup "@name"
, (SELECT UserName "User" FROM JoinedTables T2
Where t2.UserGroup = t1.UserGroup
FOR XML PATH(''), TYPE)
FROM (SELECT DISTINCT UserGroup FROM JoinedTables) t1
FOR XML PATH('UserGroup'), ROOT('UserGroupsInfo')
The code does what I want but SSMS seems to have problems with the results. Every so often, if I click on the results, instead of opening a tab showing the XML, SSMS crashes.
I'm running SP1, version 11.0.3000.0. I couldn't find a description of this problem or resolution for it in the usual places.
Anyone else seen this?
May 21, 2014 at 10:18 am
How often does this problem occur? I have run your code multiple times in my environment (11.0.3128) with no problems.
May 22, 2014 at 9:59 am
Its random. I'd say one out of 3 times on average. BTW, where did you get the update to SSMS?
May 22, 2014 at 10:16 am
A good place to start is right here: http://www.sqlservercentral.com/articles/SQL+Server+2012/87518/
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply