Skip to content

SA0269 : Datatype identifier is not in the required case

Ensure consistent casing for datatype keywords in T-SQL statements.

Maintaining a uniform case for datatype identifiers is important for code readability and maintainability. The lack of consistency in keyword casing can lead to confusion, making it harder for developers to follow and debug the code. Although SQL Server is not case-sensitive by default, maintaining consistent casing is a best practice.

For example:

-- Example of inconsistent casing in datatype declarations
CREATE TABLE SampleTable (
ID INT,
Name nvarchar(100),
CreatedDate DATETIME
);

In this example, the datatypes INT , nvarchar , and DATETIME use inconsistent casing. Choosing a consistent style, such as all uppercase or lowercase, enhances code clarity.

  • Inconsistent casing can lead to misunderstandings among team members, affecting collaboration and communication.

  • It may increase the difficulty of code management and refactoring, as developers might need to spend extra time ensuring that casing is uniform.

Ensure consistent casing for datatype identifiers in T-SQL queries to improve code readability and maintainability.

Follow these steps to address the issue:

1.Identify the datatype keywords in your T-SQL script that have inconsistent casing, such as INT , nvarchar , or DATETIME .

2.Determine the preferred case for datatype keywords according to your team’s style guide or the RequiredCase parameter configuration, such as all uppercase or lowercase.

3.Update the casing of all datatype keywords in your script to match the preferred style. This can be done manually or using a text editor’s case conversion functions.

4.Review and revise your T-SQL scripts to maintain consistent casing for all future database objects and queries.

For example:

-- Example of corrected query with consistent casing
CREATE TABLE SampleTable (
ID int,
Name nvarchar(100),
CreatedDate datetime
);

The rule has a Batch scope and is applied only on the SQL script.

Name Description Default Value
RequiredCase The parameter specifies the required case of the reserved keywords. lowercase

The rule does not need Analysis Context or SQL Connection.

2 minutes per issue.

Naming Rules, Code Smells

There is no additional info for this rule.

CREATE TABLE Test.Greeting
(
GreetingId [INT] identity (1,1) PRIMARY KEY,
Message [nvarchar](255) NOT NULL,
)
CREATE TABLE Test.Greeting1
(
GreetingId int identity (1,1) PRIMARY KEY,
Message nvarchar(255) NOT NULL,
)
CREATE TABLE Test.Greeting2
(
GreetingId Int identity (1,1) PRIMARY KEY,
Message nvarChar(255) NOT NULL,
)
CREATE TABLE Test.Greeting1
(
GreetingId INT identity (1,1) PRIMARY KEY,
Message NVARCHAR(255) NOT NULL,
)
CREATE TABLE Test.Greeting
(
GreetingId [int] identity (1,1) PRIMARY KEY,
Message [nvarchar](255) NOT NULL,
)
CREATE TABLE Test.Greeting1
(
GreetingId int identity (1,1) PRIMARY KEY,
Message nvarchar(255) NOT NULL,
)
CREATE TABLE Test.Greeting2
(
GreetingId int identity (1,1) PRIMARY KEY,
Message nvarchar(255) NOT NULL,
)
CREATE TABLE Test.Greeting1
(
GreetingId int identity (1,1) PRIMARY KEY,
Message nvarchar(255) NOT NULL,
)
  Message Line Column
1 SA0269 : Datatype identifier is not in the required case. 3 11
2 SA0269 : Datatype identifier is not in the required case. 15 11
3 SA0269 : Datatype identifier is not in the required case. 16 8
4 SA0269 : Datatype identifier is not in the required case. 21 11
5 SA0269 : Datatype identifier is not in the required case. 22 8

Analysis Rules