5 responses

  1. Craig A. Silvis
    2018-01-26

    This tip is really handy but it took me a minute to get my head around it.
    Now I use it all the time to debug by using
    –/*DEBUG
    SELECT SOME_STUFF FROM SOME_TABLE
    –*/
    Then you can do a change all on –/*DEBUG to /*DEBUG and vice versa to act as a toggle for all your debug displays.

    Reply

    • Wayne Sheffield
      2018-01-26

      That’s a neat idea Craig! When I have debug code, I usually have a @debug parameter or variable that I can use to do that. But this is also a good use of it.

      Thanks for sharing.

      Reply

  2. steve
    2018-02-26

    I like to use this approach with cte’s. You can comment out large blocks of code and test each cte section independently.

    ; with a as (
    select * from sys.databases
    )
    –select * from a /*

    , b as (
    select * from a where database_id < 10
    )
    –select * from b/*

    , c as (
    select * from b where name like '%db%'
    )

    select * from c

    –*/–*/

    Reply

Leave a Reply to let me know how you liked this post

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Back to top
mobile desktop