SQL not formatted in CTE

JimFJimF Posts: 49 Bronze 3
edited July 11, 2008 8:04AM in SQL Refactor Previous Versions

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,
USE AdventureWorks ;
WITH    DirReps(ManagerID, DirectReports)
          AS (
           * Test comment
           */SELECT ManagerID,
             FROM   HumanResources.Employee AS e
             WHERE  ManagerID IS NOT NULL
             GROUP BY ManagerID
    SELECT  ManagerID,
    FROM    DirReps
    ORDER BY ManagerID ;


  • 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.
Sign In or Register to comment.