Home

Output parameters should be assigned

Rule description

  • Output parameters should be assigned

 

Non-compliant Code Example

CREATE PROCEDURE GetImmediateManager  
   @employeeID INT,  
   @managerID INT OUTPUT   --Non compliant code (OUTPUT parameter is not assigned)
AS  
BEGIN  
   SELECT ManagerID
   FROM HumanResources.Employee
   WHERE EmployeeID = @employeeID  
END

Compliant Code Example

CREATE PROCEDURE GetImmediateManager  
   @employeeID INT,  
   @managerID INT OUTPUT  
AS  
BEGIN  
   SELECT @managerID = ManagerID  --Compliant code (OUTPUT parameter is assigned)
   FROM HumanResources.Employee
   WHERE EmployeeID = @employeeID  
END
Visual Expert 2020
 VETSQLRULE12