Mulitple rows to one row, one column

  • I have a query that uses multiple outer applies with FOR XML PATH to convert data from multiple rows to one column, one row.  The purpose is to tie user names to rows for giving user security access in another application.  This query used to run fine (albeit a little slow), but now just hangs.  I have tried everything I can possibly think of to achieve the same thing using different ways to no avail.  Can anyone make any suggestions?  Here is an example of what I need:

    Record  TeacherUserNames      AdministratorUserNames
    1            jsmith, tjones, klee     khill, pjames, cgrace

    This is a simplified version.  The reason there are multiple outer applies (STUFF does not work either) is some of the user names are joined by school, some by department, some by the teacher number, etc.  The user names can be separated into multiple columns by group or can be all in one column - it doesn't matter.  I am at a loss!  Thank you.

  • This is not enough information to even provide a guess.  

    Can you provide the structure, some sample data, the actual query, and the expected results?

    Michael L John
    If you assassinate a DBA, would you pull a trigger?
    To properly post on a forum:
    http://www.sqlservercentral.com/articles/61537/

  • Perhaps read this: http://www.sqlservercentral.com/articles/Best+Practices/61537/

    We can't see your code, we don't know the data or structure.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply