SET NOCOUNT 的最佳位置在哪里?

Where#39;s the best place to SET NOCOUNT?(SET NOCOUNT 的最佳位置在哪里?)
本文介绍了SET NOCOUNT 的最佳位置在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

对于在专用 SQL Server 上运行的大型数据库(数千个存储过程),最好在每个存储过程的顶部包含 SET NOCOUNT ON,还是在服务器级别(属性 -> 连接 -> 无计数"复选框)?这听起来像是 DRY 原则(不要重复自己"),并且该选项应该只设置在一个地方.如果 SQL Server 还托管了其他数据库,那将反对在服务器级别设置它,因为其他应用程序可能依赖于它.SET NOCOUNT 的最佳位置在哪里?

For a large database (thousands of stored procedures) running on a dedicated SQL Server, is it better to include SET NOCOUNT ON at the top of every stored procedure, or to set that option at the server level (Properties -> Connections -> "no count" checkbox)? It sounds like the DRY Principle ("Don't Repeat Yourself") applies, and the option should be set in just one place. If the SQL Server also hosted other databases, that would argue against setting it at the server level because other applications might depend on it. Where's the best place to SET NOCOUNT?

推荐答案

将其设为服务器的默认设置(除历史原因外,将设为默认设置).我从一开始就对所有服务器执行此操作.有没有想过为什么它是 SET NOCOUNT ON 而不是 SET COUNT OFF?这是因为在 Sybase 时代,唯一的 UI 是 CLI;当查询可能没有结果时显示计数是很自然的,因此没有指示它已完成.

Make it the default for the server (which it would be except for historical reasons). I do this for all servers from the start. Ever wonder why it's SET NOCOUNT ON instead of SET COUNT OFF? It's because way way back in Sybase days the only UI was the CLI; and it was natural to show the count when a query might show no results, and therefore no indication it was complete.

这篇关于SET NOCOUNT 的最佳位置在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Number of working days between two dates(两个日期之间的工作日数)
How do I use dateadd to get the first day of last year?(如何使用 dateadd 获取去年的第一天?)
SQL- Count occurrences of a specific word within all stored procedures(SQL- 计算所有存储过程中特定单词的出现次数)
SQL query to make a column of numbers a string(使一列数字成为字符串的 SQL 查询)
T-SQL: Best way to replace NULL with most recent non-null value?(T-SQL:用最新的非空值替换 NULL 的最佳方法?)
Count days in date range with set of exclusions which may overlap(使用一组可能重叠的排除项计算日期范围内的天数)