DF038: The constraint name is not explicitly specified.
Last modified: May 28, 2025
The topic describes the DF038 T-SQL code analysis rule.
Category
NAMING CONVENTIONS
Message
The constraint name is not explicitly specified.
Description
To facilitate database maintenance, it is recommended to explicitly name constraints so that they can be easily referenced when needed.
Additional information
When the constraint name is not explicitly specified in SQL, the DBMS automatically generates a default name for the constraint, typically combining the table name with a system-generated identifier. This can lead to less readable and harder-to-manage schema definitions, making tasks like error resolution and constraint modification more challenging due to the non-descriptive and unpredictable default names.
Noncompliant code example
CREATE TABLE dbo.Customers(
CustomerId INT PRIMARY KEY CLUSTERED,
CustomerName VARCHAR(255) NOT NULL
);
Compliant solution
CREATE TABLE dbo.Customers(
CustomerId INT CONSTRAINT PK_Customers PRIMARY KEY CLUSTERED,
CustomerName VARCHAR(255) NOT NULL
);
Want to find out more?
Overview
Take a quick tour to learn all about the key benefits delivered by dbForge Studio for SQL Server.
All features
Get acquainted with the rich features and capabilities of the tool in less than 5 minutes.
Request a demo
If you consider employing this tool for your business, request a demo to see it in action.