Quantcast
Channel: Data being truncate from FOR XML PATH
Viewing all articles
Browse latest Browse all 6

Data being truncate from FOR XML PATH

0
0

Hello,

I have the following TSQL below, the Branches field has been truncated out most of the field content.

WITH c
     AS (SELECT TOP (100) PERCENT Indicator, 
                                  CAST(BranchName AS NVARCHAR(MAX)) AS Branch, 
                                  Mth
         FROM [IAD].dbo.SQLDataSource
         ORDER BY Indicator, 
                  BranchName)
     SELECT c.mth AS [Month], 
            c.Indicator, 
            COUNT(c.branch) AS cnt, 
            STUFF(
     (
         SELECT '; ' + x.Branch
         FROM
         (
             SELECT TOP (100) PERCENT Indicator, 
                                      CAST(BranchName AS NVARCHAR(MAX)) AS Branch, 
                                      Mth
             FROM dbo.SQLDataSource
             GROUP BY Indicator, 
                      BranchName, 
                      Mth
             ORDER BY Branch
         ) x
         WHERE c.Indicator = x.Indicator
               AND c.Mth = x.Mth
         ORDER BY Branch FOR XML PATH('')
     ), 1, 1, '') [Branches]
     FROM c
     GROUP BY c.Mth, 
              c.Indicator
     ORDER BY 1 DESC;

How could I return the full data from the Branches field?

Sam


Viewing all articles
Browse latest Browse all 6

Latest Images

Trending Articles





Latest Images