Click or drag to resize

SA0246 : Stored procedure executed with incorrect arguments

The topic describes the SA0246 analysis rule.

Message

Stored procedure executed with incorrect arguments

Description

The rule checks T-SQL code for stored procedures called with incorrect or missing required arguments.

These are the cases when an invalid argument rule violation is reported:

-The procedure does not have such parameter.

-The procedure is called with argument as OUTPUT, but parameter is not declared as such.

-The procedure parameter is declared as OUTPUT, but is not specified as such.

- The procedure parameter is specified more than once in the procedure call

- The procedure parameter, which has no default value specified is not supplied.

Scope

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

Parameters

Rule has no parameters.

Remarks

The rule requires SQL Connection. If there is no connection provided, the rule will be skipped during analysis.

Categories

Design Rules

Additional Information

There is no additional info for this rule.

Example Test Script
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 out,'20050225', 1223 ;
13EXEC @result = uspGetWhereUsedProductID
14EXEC TestReturnPlanForEX0018_Encrypted_Numbered;3 123

Analysis Results

 MessageLineColumn
1SA0246 : The procedure parameter is specified more than once in the procedure call.334
2SA0246 : The procedure does not have such parameter.545
3SA0246 : The procedure does not have such parameter.1058
4SA0246 : The procedure is called with parameter as OUTPUT, but parameter is not declared as such.1246
5SA0246 : The procedure does not have such parameter.1258
6SA0246 : The procedure does not have such parameter.1270
7SA0246 : Procedure expects parameter @StartProductID, which was not supplied.1315
8SA0246 : Procedure expects parameter @CheckDate, which was not supplied.1315
9SA0246 : The procedure does not have such parameter.1450
See Also

Other Resources