Skip to content

SA0061A : Check all Tables in the current database for following specified naming convention

Inconsistent or unclear table naming conventions can lead to confusion and difficulties in maintenance.

In SQL Server, maintaining consistent and descriptive naming conventions for database objects, such as tables, is critical for readability, maintainability, and collaboration. Poorly named tables can result in confusion and increased complexity in database management.

For example:

-- Example of a table with inconsistent naming
CREATE TABLE tblData_Store (
ID INT,
Name VARCHAR(100)
);

Using inconsistent or unclear table names like tblData_Store can cause several issues:

  • Lack of clarity about the table’s purpose or content, leading to misunderstandings among developers and database administrators.

  • Difficulty in managing or modifying SQL queries, as inconsistent naming requires more time to decipher and adjust existing code structures.

Ensure table names adhere to naming conventions for consistency and clarity.

Follow these steps to address the issue of improper table naming conventions:

1.Identify tables with inconsistent or unclear names. Use INFORMATION_SCHEMA.TABLES to list all tables in your database.

2.Develop a consistent naming convention that aligns with your organization’s standards. For example, use the prefix tbl for all table names followed by a descriptive noun that captures the table’s purpose.

3.Rename tables to adhere to the established naming convention. Use the sp_rename function in SQL Server Management Studio (SSMS) to rename tables. Note, this operation should be carefully planned to avoid disrupting application dependencies.

For example:

-- Example of renaming a table to follow naming conventions
EXEC sp_rename 'tblData_Store', 'tblStoreData';

The rule has a ContextOnly scope and is applied only on current server and database schema.

Name Description Default Value
NamePattern Table name pattern. regexp:[A-Z][A-Za-z]+
SchemaQualifiedNamePattern Schema qualified name pattern. -

The rule requires Analysis Context. If context is missing, the rule will be skipped during analysis.

13 minutes per issue.

Naming Rules, Code Smells

There is no additional info for this rule.

Analysis Rules