SA0185 : Review the call for unintentionally passing the same value more than once as an argument

The topic describes the SA0185 analysis rule.

Message

Review the call for unintentionally passing the same value more than once as an argument

Description

The rule checks SQL code for function or procedure calls for having the same values passed more than once as argument.

How to fix

nReview your code and suppress the rule violation if the code is correct and the duplicated arguments are intentional.

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
 1Test.Greeting 'message', 'message'
 2
 3declare @Message nvarchar(100) = 'hi'
 4declare @Name nvarchar(10) = 'George'
 5
 6exec Test.Greeting  @param1 = @Message, @param2 = @Message
 7exec Test.Greeting  @Message, @Message
 8exec Test.Greeting  @Name, @Message, @Name 
 9
10select isnull(message,message) from dbo.Greetings
11select isnull(message,'hello') from dbo.Greetings
12select isnull(@Name, @Message, @Name ) from dbo.Greetings
13select dbo.myFunction(name,name,message ) from dbo.Greetings
14
15
16select dbo.myFunction(1,2,10,1 ) from dbo.Greetings

Analysis Results
  Message Line Column
1 SA0185 : Value appears more than once in the procedure arguments. 1 14
2 SA0185 : Value appears more than once in the procedure arguments. 7 20
3 SA0185 : Value appears more than once in the procedure arguments. 8 20
4 SA0185 : Value appears more than once in the function arguments. 10 14
5 SA0185 : Value appears more than once in the function arguments. 12 14
6 SA0185 : Value appears more than once in the function arguments. 13 22
7 SA0185 : Value appears more than once in the function arguments. 16 22
See Also

Other Resources