Click or drag to resize

SA0043B : Avoid using reserved words for type names

The topic describes the SA0043B analysis rule.

Message

Avoid using reserved words for type names

Description

The rule checks the T-SQL code for creation of user defined types using a reserved word as a type name.

You should avoid using a reserved word as the name of a user-defined type because readers will have a harder time understanding your database code. You can use reserved words in SQL Server as identifiers and object names only if you use delimited identifiers.

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

Additional Information

There is no additional info for this rule.

Example Test Script
SQL
 1--  keyword as a type name misuse
 2CREATE TYPE dbo.[Alter] FROM varchar(11) NOT NULL ; --  'Alter' is a reserved keyword
 3CREATE TYPE [Order] FROM varchar(11) NOT NULL ; --  'Order' is a reserved keyword
 4
 5
 6
 7EXEC sp_addtype N'Alter', N'char(10)',N'not null' --  'Alter' is a reserved keyword
 8EXEC sp_addtype N'Table', N'char(10)',N'not null' --  'Table' is a reserved keyword
 9EXEC sp_addtype N'Order', N'char(10)',N'not null' --  'Order' is a reserved keyword
10
11
12EXEC sp_addtype N'', N'char(10)',N'not null' --  'Order' is a reserved keyword
13
14
15EXEC sys.sp_addtype [Alter], N'char(10)',N'not null' --  Alter is a reserved keyword
16EXEC sp_addtype dbo.[Alter], N'char(10)',N'not null' --  Alter is a reserved keyword
17
18
19EXEC sp_addtype N'AlterType', N'char(10)',N'not null'
20
21EXEC sp_addtype N'TableType', N'char(10)',N'not null'

Analysis Results

 MessageLineColumn
1SA0043B : Avoid using reserved words for type names.316
2SA0043B : Avoid using reserved words for type names.412
3SA0043B : Avoid using reserved words for type names.816
4SA0043B : Avoid using reserved words for type names.916
5SA0043B : Avoid using reserved words for type names.1016
6SA0043B : Avoid using reserved words for type names.1620
7SA0043B : Avoid using reserved words for type names.1720
See Also

Other Resources