To get comma separated list in SQL as well as in MDX use below queries.

1 – SQL

Select Name from Sales.SalesReason

GO

Select Name from Sales.SalesReason

SELECT

SUBSTRING

(

(

SELECT

‘,’ + s.Name

FROM

Sales.SalesReason  s

ORDER BY

s.Name

FOR XML PATH(”)

)

,2,200000 ) AS NAME

1_SQL_Server_Get_a_comma_separated_list_in_SQL_MDX.

2 – MDX

WITH

SET [COMMA] AS [Sales Reason].[Sales Reasons].[Sales Reason].MEMBERS

MEMBER [MEASURES].[COMMATEST] AS

Generate

(

[COMMA]

,[COMMA].CurrentMember.Name

,”,”

)

SELECT

NON EMPTY

{

[MEASURES].[COMMATEST]

} ON 0

FROM

[ADVENTURE WORKS];

2_SQL_Server_Get_a_comma_separated_list_in_SQL_MDX

 

Regards

Suhas Kudekar

Like us on FaceBook Follow us on Twitter | Join the fastest growing SQL Server group on FaceBook

Follow me on TwitterFollow me on FaceBook