Home

NOCOUNT should be activated on PROCEDURE and TRIGGER definitions

Rule description

  • NOCOUNT should be activated on PROCEDURE and TRIGGER definitions

 

Non-compliant Code Example

CREATE PROCEDURE [dbo].[GetAllProducts] --Non compliant code (NOCOUNT is not activated on the procedure)
AS
BEGIN
    -- Insert statements for procedure here
	SELECT * From Production.Product
END
GO

Compliant Code Example

CREATE PROCEDURE [dbo].[GetAllProducts] 
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from interfering with SELECT statements.
	SET NOCOUNT ON;  --Compliant code (NOCOUNT is activated on the procedure)

    -- Insert statements for procedure here
	SELECT * From Production.Product
END
GO
Visual Expert 2020
 VETSQLRULE60