Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
paulmoss
Starting Member
14 Posts |
Posted - 2011-12-15 : 12:44:55
|
I am currently trying to create a script that will merge the contents of indivial rows based on the contents of another. For example we have the following informationID Dated Notes1 01/01/11 Started Project1 15/01/11 Have Spoken to Mike all ok1 25/02/11 Mike has won the contract2 01/01/11 Started Project2 31/01/11 Project lost to competitorWhat I want to out put is the followingID Notes1 01/01/11 - Started Project. 15/01/11 - Have Spoken to Mike all is ok. 25/02/11 - Mike has won the project2 01/01/11 - Started Project. 31/01/11 - Project lost to competitorOr into a similar format. Any help that you can provide would be greatley appreciatedMany thanksPaul |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-12-15 : 12:49:24
|
[code]SELECT ID,STUFF((SELECT '.' + CONVERT(varchar(8),Dated,3) + ' - ' + Notes FROM Table WHERE ID = t.ID ORDER BY Dated FOR XML PATH('')),1,1,'')FROM (SELECT DISTINCT ID FROM Table)t[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|