Click or drag to resize

SA0231 : The used parameter or variable has different case than its declaration

The topic describes the SA0231 analysis rule.

Message

The used parameter or variable has different case than its declaration

Description

The rule checks T-SQL code for parameters and variables referenced using case different from their declaration.

Using inconsistent variable case will break the code if deployed on case sensitive server instance.

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.

Categories

Naming Rules, New Rules

Additional Information

There is no additional info for this rule.

Example Test Script
SQL
 1create procedure SampleProcedure
 2@EmployeeIDParm int,
 3@EmployeeFirstnameParm nvarchar(50),
 4@EmployeeLastnameParm nvarchar(50),
 5@maxTotal int output
 6as 
 7begin
 8    declare @myCounter int;
 9    declare @lastName nvarchar(30),
10            @firstName nvarchar(20),
11            @StateProvince nchar(2);
12
13    execute @MyCounter=sp_executesql 'select 1,2,3',
14            @params='',
15            @EmployeeIDParm=1,
16            @EmployeelastnameParm=@EmployeelastnameParm,
17            @EMPLOYEEIDPARM,
18            @maxTotal=@maxTotal output;
19
20    select @maxtotal,
21           @EmployeeLastNameParm,
22           @stateProvince,
23           @firstName,
24           @lastname;
25
26    return 1
27end

Analysis Results

 MessageLineColumn
1SA0231 : The reference @EMPLOYEEIDPARM is used with different case than the declared parameter @EmployeeIDParm.1712
2SA0231 : The reference @EmployeelastnameParm is used with different case than the declared parameter @EmployeeLastnameParm.1634
3SA0231 : The reference @EmployeeLastNameParm is used with different case than the declared parameter @EmployeeLastnameParm.2111
4SA0231 : The reference @maxtotal is used with different case than the declared parameter @maxTotal.2011
5SA0231 : The reference @MyCounter is used with different case than the declared variable @myCounter.1312
6SA0231 : The reference @lastname is used with different case than the declared variable @lastName.2411
7SA0231 : The reference @stateProvince is used with different case than the declared variable @StateProvince.2211
See Also

Other Resources