SA0029 : Input parameter never used

The topic describes the SA0029 analysis rule.

Message

Input parameter never used

Description

This rule checks for not used stored procedure or function input parameters. Unused parameters not necessarily negatively affect the performance, but they just add bloat to your stored procedures and functions.

How to fix

Review the stored procedure and remove the unused input parameter.

Scope

The rule has a Batch scope and is applied only on the SQL script.

Parameters

Rule has no parameters.

Remarks

The rule does not need Analysis Context or SQL Connection.

Effort To Fix
2 minutes per issue.
Categories

Design Rules, Code Smells

Additional Information

There is no additional info for this rule.

Example Test SQL
SQL
 1CREATE PROCEDURE Production.uspGetList 
 2
 3      @Product varchar(40) 
 4        , @VendorCode varchar(20) -- parameter is not used
 5        , @VendorCode2 varchar(20) -- parameter is not used, but the rule is suppressed because this comment contains 'IGNORE:SA0029' text.
 6    , @MaxPrice money 
 7    , @ComparePrice money OUTPUT
 8    , @ListPrice money OUT
 9    , @input int -- parameter is only assigned, but not used
10AS
11    SET NOCOUNT ON;
12
13    SET @input = 0 
14    SELECT p.[Name] AS Product, p.ListPrice AS 'List Price'
15    FROM Production.Product AS p
16    JOIN Production.ProductSubcategory AS s 
17      ON p.ProductSubcategoryID = s.ProductSubcategoryID
18    WHERE s.[Name] LIKE @Product AND p.ListPrice < @MaxPrice;
19-- Populate the output variable @ListPprice.
20SET @ListPrice = (SELECT MAX(p.ListPrice)
21        FROM Production.Product AS p
22        JOIN  Production.ProductSubcategory AS s 
23          ON p.ProductSubcategoryID = s.ProductSubcategoryID
24        WHERE s.[Name] LIKE @Product AND p.ListPrice < @MaxPrice);
25-- Populate the output variable @compareprice.
26SET @ComparePrice = @MaxPrice;

Analysis Results
  Message Line Column
1 SA0029 : The input parameter @VendorCode never used. 4 3
2 SA0029 : The input parameter @input never used. 9 6
See Also

Other Resources