Click or drag to resize

SA0153 : Always specify parameter names when calling stored procedures

The topic describes the SA0153 analysis rule.

Message

Always specify parameter names when calling stored procedures

Description

The rule checks EXECUTE statements for stored procedure not being called with named parameters, but with parameters by position.

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.

Categories

Design Rules

Additional Information
Example Test Script
SQL
 1USE AdventureWorks2012;
 2
 3-- Passing values as constants.
 4EXEC dbo.uspGetWhereUsedProductID 819, '20050225';
 5
 6-- Passing values as variables.
 7DECLARE @ProductID int, @CheckDate datetime;
 8SET @ProductID = 819;
 9SET @CheckDate = '20050225';
10EXEC dbo.uspGetWhereUsedProductID @ProductID, @CheckDate;
11
12-- Try to use a function as a parameter value.
13-- This produces an error message.
14--EXEC dbo.uspGetWhereUsedProductID 819, GETDATE();
15
16-- Passing the function value as a variable.
17
18SET @CheckDate = GETDATE();
19EXEC dbo.uspGetWhereUsedProductID 819, @CheckDate;
20
21
22EXECUTE my_proc @second = 2, @first = 1, @third = 3;
23
24exec my_proc @second = 2, @first = 1, @third = 3;

Analysis Results

 MessageLineColumn
1SA0153 : Always specify parameter names when calling stored procedures.40
2SA0153 : Always specify parameter names when calling stored procedures.100
3SA0153 : Always specify parameter names when calling stored procedures.190
See Also

Other Resources