DF158: An unnamed parameter is used after a named parameter in the EXECUTE procedure statement.

Last modified: December 25, 2024

The topic describes the DF158 T-SQL code analysis rule.

Category

EXECUTION RULES

Message

An unnamed parameter is used after a named parameter in the EXECUTE procedure statement.

Description

If the parameter name is used for any parameter, it must be used for all subsequent parameters.

Additional information

When mixing named and unnamed parameters, there is a risk of misalignment between the parameters passed to the procedure and the parameters expected by the procedure. This can result in incorrect data being passed to the procedure or in the procedure not functioning as intended.

This can also make the code less readable and harder to maintain. In case of errors or unexpected behavior, debugging becomes more challenging and identifying the source of the problem can be more time-consuming and error-prone.

Noncompliant code example

EXEC @Result = dbo.DemoProcedure @x = 12
                                ,10
GO

Compliant solution

EXEC @Result = dbo.DemoProcedure @x = 12
                                ,@y = 10
GO