SA0250 : Consider calling procedures with named arguments

The topic describes the SA0250 analysis rule.

Message

Consider calling procedures with named arguments

Description

The rule check T-SQL code for procedure calls using unnamed arguments.

It is recommended to specify the argument name when executing a stored procedure.

While it is entirely legal to use an ordered list of unnamed arguments, in case a new parameter is added in the middle of the parameters list, having a named arguments could prevent problems with the existing execute statements of the procedue.

How to fix

Specify name to each argument when executing a stored procedure.

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
5 minutes per issue.
Categories

Design Rules, Code Smells

Additional Information

There is no additional info for this rule.

Example Test SQL
SQL
 1DECLARE  @result INT
 2EXEC @result = uspGetWhereUsedProductID  819, '20050225';
 3EXEC uspGetWhereUsedProductID;1   123, @CheckDate = '20050225', @StartProductID = 819;
 4
 5EXEC uspGetWhereUsedProductID   @NoSuchParam = 123, @CheckDate = '20050225', @StartProductID = 819;
 6
 7EXECUTE  AdventureWorks2008R2_Test.dbo.uspGetWhereUsedProductID  @StartProductID = 819, @CheckDate = '20050225';
 8
 9
10EXEC @result = uspGetWhereUsedProductID  819, '20050225', 122;
11DECLARE @output int
12EXEC @result = uspGetWhereUsedProductID  819, @output output,'20050225', 1223 ;
13EXEC @result = uspGetWhereUsedProductID
14EXEC TestReturnPlanForEX0018_Encrypted_Numbered;3 123

Analysis Results
  Message Line Column
1 SA0250 : Consider calling procedures with named arguments. 2 15
2 SA0250 : Consider calling procedures with named arguments. 3 5
3 SA0250 : Consider calling procedures with named arguments. 10 15
4 SA0250 : Consider calling procedures with named arguments. 12 15
5 SA0250 : Consider calling procedures with named arguments. 14 5
See Also

Other Resources