What are the advantages and disadvantages of turning NOCOUNT off in SQL server queries?

后端 未结 7 659
故里飘歌
故里飘歌 2021-01-04 03:35

What are the advantages and disadvantages of turning NOCOUNT off in SQL server queries? ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­

7条回答
  •  -上瘾入骨i
    2021-01-04 04:06

    I personally like to turn NOCOUNT on for queries that get run in an manual fashion and use a lot of Print statements to output debugging messages. In this way, your output would look less like:

    Updating usernames
    (287 rows updated)
    
    Done
    Updating passwords
    (287 rows updated)
    
    Done
    Doing the next thing
    (1127 rows updated)
    
    Done
    

    And more like

    Updating usernames
    Done
    
    Updating passwords
    Done
    
    Doing the next thing
    Done
    

    Depending on the sensitivity of what you're updating, sometimes it is helpful to include the counts; however, for complex scripts with a lot of output I usually like to leave them out.

提交回复
热议问题