問題描述
對于在專用 SQL Server 上運行的大型數(shù)據(jù)庫(數(shù)千個存儲過程),最好在每個存儲過程的頂部包含 SET NOCOUNT ON
,還是在服務(wù)器級別(屬性 -> 連接 -> 無計數(shù)"復(fù)選框)?這聽起來像是 DRY 原則(不要重復(fù)自己"),并且該選項應(yīng)該只設(shè)置在一個地方.如果 SQL Server 還托管了其他數(shù)據(jù)庫,那將反對在服務(wù)器級別設(shè)置它,因為其他應(yīng)用程序可能依賴于它.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
?
推薦答案
將其設(shè)為服務(wù)器的默認設(shè)置(除歷史原因外,將設(shè)為默認設(shè)置).我從一開始就對所有服務(wù)器執(zhí)行此操作.有沒有想過為什么它是 SET NOCOUNT ON 而不是 SET COUNT OFF?這是因為在 Sybase 時代,唯一的 UI 是 CLI;當查詢可能沒有結(jié)果時顯示計數(shù)是很自然的,因此沒有指示它已完成.
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.
這篇關(guān)于SET NOCOUNT 的最佳位置在哪里?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!