Wednesday, July 5, 2017

SQL Server Stored Procedure Performance

To improve Stored Procedure Performance put this line  for life saver
SET NOCOUNT ON;

By using this one line of code, put at the top of a stored procedure turns off the messages that SQL Server sends back to the client after each T-SQL statement is executed. This is performed for all SELECT, INSERT, UPDATE, and DELETE statements.

For Reference
https://docs.microsoft.com/en-us/sql/t-sql/statements/set-nocount-transact-sql

https://www.mssqltips.com/sqlservertip/1226/set-nocount-on-improves-sql-server-stored-procedure-performance/

http://www.sqlservercentral.com/articles/Performance+Tuning/2751/



CREATE PROCEDURE sp_test

AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;



END
GO

No comments:

Post a Comment