Home

Duplicate values should not be passed as arguments

Description

    The "Duplicate values should not be passed as arguments" SQL Server code rule states that when passing arguments to a stored procedure or function, any duplicate values should not be included. This is to avoid any potential issues with the code, such as an unexpected result or an error. By not including duplicate values, the code will be more reliable and efficient. In some cases, it may also be necessary to check the data type of the argument to ensure that they are compatible with the data type of the parameter. This code rule helps to ensure that the code is robust and reliable.

Key Benefits

  • Eliminates Unnecessary Duplication: By not passing duplicate values as arguments, unnecessary duplication is eliminated, making code more efficient and easier to maintain.
  • Reduces Complexity: By avoiding passing duplicate values as arguments, the logic of the code is simplified, making it easier to understand and debug.
  • Improves Performance: By avoiding passing duplicate values as arguments, code runs faster, improving overall performance.

 

Non-compliant Code Example

DECLARE @p varchar(50);
DECLARE @name varchar(50);
SET @name = dbo.GetText(@p, @p); --Non compliant code (Duplicate variable/values passed as arguments)
Visual Expert 2024
 VETSQLRULE69