Competition: What’s your favorite Redgate tool? Enter now.

Comments are formatted wrong

edited August 26, 2016 8:14AM in SQL Prompt
Comments are formatted wrong



SQL Prompt 7.3.0.437 will format the following
/*******************************************************************************

troubleshooting queries - query_hash and query_plan_hash

********************************************************************************/

/*

query_hash 
	Binary hash value calculated on the query and used to identify queries with 
	similar logic. 
	You can use the query hash to determine the aggregate resource usage for 
	queries that differ only by literal values.

*/

like this: (too many empty lines added with Whitespace / Preserve existing new lines between statements)
/*******************************************************************************

troubleshooting queries - query_hash and query_plan_hash

********************************************************************************/
--too many line here
--too many line here
--too many line here
--too many line here
--too many line here
/*

query_hash 
	Binary hash value calculated on the query and used to identify queries with 
	similar logic. 
	You can use the query hash to determine the aggregate resource usage for 
	queries that differ only by literal values.

*/




or like this: (no empty lines added with Whitespace / empty lines between statements 1)


/*******************************************************************************

troubleshooting queries - query_hash and query_plan_hash

********************************************************************************/
--missing a line before /*

query_hash 
	Binary hash value calculated on the query and used to identify queries with 
	similar logic. 
	You can use the query hash to determine the aggregate resource usage for 
	queries that differ only by literal values.

*/

In both cases the format is wrong.

Should look like
/*******************************************************************************

troubleshooting queries - query_hash and query_plan_hash

********************************************************************************/
--one line here as configured
/*

query_hash 
	Binary hash value calculated on the query and used to identify queries with 
	similar logic. 
	You can use the query hash to determine the aggregate resource usage for 
	queries that differ only by literal values.

*/

Thanks!

Comments

  • Hi Torsten,

    Thanks for you post - We've been able to reproduce it and think we have a fix in the latest beta build (7.3.0.450). Please give it a try and let us know if it works as you'd expect.

    Thanks!
    Aaron.
  • Fixed - thanks but I guess the behavior is still worng:
    /*******************************************************************************
    
    	troubleshooting queries
    
    ********************************************************************************/
    
    /*******************************************************************************
    
    	troubleshooting queries - sys.dm_exec_requests
    
    ********************************************************************************/
    
    /*
    	
    	sys.dm_exec_requests
    	Returns information about each request that is executing within SQL Server
    
    */
    
    SELECT *
    FROM sys.dm_exec_requests;
    GO
    SELECT 1;
    


    I would like to preserve the lines between the comments but would like to apply the formatting rules on the statement.

    This is the outcome:
    /*******************************************************************************
    
    	troubleshooting queries
    
    ********************************************************************************/
    --no line anymore - wrong
    /*******************************************************************************
    
    	troubleshooting queries - sys.dm_exec_requests
    
    ********************************************************************************/
    --no line anymore - wrong
    /*
    	
    	sys.dm_exec_requests
    	Returns information about each request that is executing within SQL Server
    
    */
    --no line anymore - wrong
    SELECT *
    FROM sys.dm_exec_requests;
    GO
    --new line correct
    SELECT 1;
    


    Thanks for your support!
  • Hi Torsten,

    Just to clarify, are you saying that you have Preserve empty lines between statements turned off, but you'd like to still preserve empty lines between comments?

    Best regards,

    David
  • Hi David,

    the lines between the comments were deleted which is wrong.
    Between the SQL statements the added line is correct.

    Seems that the formatting rules will be handled differently between comments and SQL code which is not my expectation....
  • Hi Torsten,

    I've found what was causing this and improved the logic, so we'll include this in the next release. Hopefully this will solve your problem.

    Best regards,

    David
Sign In or Register to comment.