How can we help you today? How can we help you today?

Merge and HOLDLOCK in Sql Prompt

I understand this is picky, but I notice that when I use the table hint for HOLDLOCK in a T-SQL MERGE statement that SQL Prompt gives me a green squiggly and says that table hints should be avoided.  As a general guideline, I agree.

In the case of the MERGE statement as implemented by Microsoft SQL Server, I have come to understand that if this table hint is not used it leads to race conditions.  I would wonder if in this particular case, SQL Prompt would not call it out, and in fact, for SQL Server, actually squiggle me if the hint is missing?

Robert Sailors
0

Comments

1 comment

  • Jon Kirkwood
    Official comment

    Hi Robert Sailors 

     

    Thank you for reaching out on the Redgate forums regarding your SQL Prompt rule triggering. 

     

    SQL Prompt's PE006 rule currently flags all table hints without context, so it can't distinguish this from a genuinely unnecessary hint such as the one you're hitting. 

     

    The suggested workaround for now: PE006 can be disabled globally via Code analysis rules > Performance rules > PE006 

     

    Worth noting, there's currently no way to suppress a rule for a specific statement only. This would be a feature request. 

    I've had a search of our UserVoice feature request site and found a couple of existing feature requests that look similar to what you are looking for. 

    I would recommend viewing these and providing a vote & comment so it can be seen by our developers.

    Link here: https://redgate.uservoice.com/forums/94413-sql-prompt?query=pe006

    Jon Kirkwood

Add comment

Please sign in to leave a comment.