SQL not formatted in CTE

JimFJimF Posts: 48 Bronze 2
edited July 11, 2008 8:04AM in SQL Refactor Previous Versions
Hello,

This is a minor issue, but if you have a multiline comment in a CTE, the first line of T-SQL is put next to the close of the comment instead of on the next line. See sample below.

Thank you,
Jim
USE AdventureWorks ;
GO
WITH    DirReps(ManagerID, DirectReports)
          AS (
          /*
           * Test comment
           */SELECT ManagerID,
                    COUNT(*)
             FROM   HumanResources.Employee AS e
             WHERE  ManagerID IS NOT NULL
             GROUP BY ManagerID
             )
    SELECT  ManagerID,
            DirectReports
    FROM    DirReps
    ORDER BY ManagerID ;
GO

Comments

  • Thanks for your post.

    I have been able to reproduce the issue using your example. It seems that in a CTE, a comment block before a SELECT or AS statement will not be displayed on a different line.

    I have added a record of this in our bug tracking system. (SR-780)

    Once approved, a fix will be scheduled into a future version.
    Chris
Sign In or Register to comment.