troubleshooting Question

Concatenate rows

Avatar of Taras
TarasFlag for Canada asked on
DatabasesMicrosoft SQL Server
7 Comments3 Solutions162 ViewsLast Modified:
I have table tblNote in SQLServer database

with next fields

Note_ID            Note_Date                    CreatedBy              Notes
1                 2014-06-25 18:47:03      John Borkovic      Test Note adfadf
1                 2014-06-25 18:52:28      Jim Jonson              Test Note adfadf
2                 2014-06-25 18:55:05      Bill Smith              Test Notes alkdfakd
3                 2014-06-25 18:58:31      Kathy Story              Test Notes alkdl
3                 2014-06-25 19:27:30      Bill Smith              Test Notes abagab
......
I need script that will do merge - Concatenate those rows per Note ID to look like

Note_ID            NoteDate_1                    CreatedBy_1              Notes_1                        NoteDate_2                   CreatedBy_2               Note_2
1                 2014-06-25 18:47:03      John Borkovic      Test Note adfadf             2014-06-25 18:52:28      Jim Jonson               Test Note adfadf
2            2014-06-25 18:55:05      Bill Smith              Test Notes alkdfakd             Null                                   Null                      Null
3            2014-06-25 18:58:31      Kathy Story               Test Notes alkdl              2014-06-25 19:27:30      Bill Smith                Test Notes abagab


Per one Note_ID I could have more entries here I my example I have the most two,
 but it could be up to 30 entries per Note ID, so I could  have 30 x 3 = 90 columns in result.
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 3 Answers and 7 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 3 Answers and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros