Advertisements
Home > Business Intelligence > Get a comma separated list in SQL & MDX.

Get a comma separated list in SQL & MDX.

To get a 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

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

Suhas R. Kudekar(MCC)

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: