SA0016 : Use of very small variable length type (size 1 or 2)

The topic describes the SA0016 analysis rule.

Message

Use of very small variable length type (size 1 or 2)

Description

This rule checks for use of very small variable length type (with size of 1 or 2).

It is recommended to use fixed length data type when size is less than 3. Variable length type with size less than 3 consumes more space than the same fixed length type.

How to fix

Use fixed length data type when size is less than 3.

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
2 minutes per issue.
Categories

Performance Rules, Bugs

Additional Information

There is no additional info for this rule.

Example Test SQL
SQL
1DECLARE @var nvarchar(1) -- too small variant length type
2DECLARE @var1 nchar(1) -- fixed length type
3DECLARE @var2 varchar(1) -- too small variant length type
4DECLARE @var3 char(1)-- fixed length type
5DECLARE @var4 nvarchar(2) -- too small variant length type
6DECLARE @var5 nchar(2) -- fixed length type
7DECLARE @var6 varchar(2) -- too small variant length type
8DECLARE @var7 char(2) -- fixed length type

Analysis Results
  Message Line Column
1 SA0016 : Use of very small variable length type (size 1 or 2). 1 22
2 SA0016 : Use of very small variable length type (size 1 or 2). 3 22
3 SA0016 : Use of very small variable length type (size 1 or 2). 5 23
4 SA0016 : Use of very small variable length type (size 1 or 2). 7 22
See Also

Other Resources