From: Plamen Ratchev on 20 Apr 2010 10:32 Instead of using recursive CTE you can use FOR XML PATH to concatenate the rows: SELECT DISTINCT A.[Key], C.data FROM DataTable AS A CROSS APPLY (SELECT '' + B.Data FROM DataTable AS B WHERE B.[Key] = A.[Key] ORDER BY B.[No] FOR XML PATH('')) AS C(data); -- Plamen Ratchev http://www.SQLStudio.com
From: Simon Woods on 20 Apr 2010 10:59 Fantastic ... thx vm On 20/04/2010 15:32, Plamen Ratchev wrote: > Instead of using recursive CTE you can use FOR XML PATH to concatenate > the rows: > > SELECT DISTINCT A.[Key], C.data > FROM DataTable AS A > CROSS APPLY (SELECT '' + B.Data > FROM DataTable AS B > WHERE B.[Key] = A.[Key] > ORDER BY B.[No] > FOR XML PATH('')) AS C(data); >
From: --CELKO-- on 20 Apr 2010 13:08 You do not do this in SQL or in RDBMS. We have this thing called First Normal Form. We really like it since it is the foundation of the RM. Use a report writer or application program to do display and front-end work. You can also uses proprietary XML extensions, but that just screams that you are not an SQL programmer at heart and want to lock into Microsoft.
|
Pages: 1 Prev: Database Tuning Advisor - Cannot Initialize Tuning Next: Help with query |