liveBook · Manning

Naming standard

As explained in 100 SQL Server Mistakes and How to Avoid Them

A naming convention is a prescribed pattern for naming software elements such as schemas, tables, columns, or code symbols.

A naming standard prescribes how databases, instances, tables, procedures, parameters, and other software elements are named. Its purpose is not cosmetic consistency: meaningful names make an environment and its code easier to identify, read, and maintain. Names should let a reader who knows the language infer what an object is trying to do. section 2.0 section 2.2

A memorable mistake is choosing short, generic names because they seem quick and harmless. Names such as SQL01, proc01, tbl03, updateStock, and stockUpdate force an investigator to inspect definitions before knowing which object is relevant. That lost time compounds during debugging, handovers, and production incidents. section 2.1 section 2.2

Use a naming standard to make intent visible without relying on comments alone:

  • Choose descriptive object, procedure, and parameter names that distinguish purpose and role, such as billing versus delivery address or order quantity versus product ID. section 2.2
  • Treat names as operational interfaces: select them so that object lists and procedure calls help a new maintainer locate the right target. section 2.2
  • Plan instance names for organizational change. Names tied only to one application can become confusing when applications are consolidated; names tied only to departments can also break down after restructures. section 8.1
  • Define the convention for the organization and deployment context rather than assuming one universal instance-name pattern fits every environment. section 8.1 section 8.11

Diagnosing an ambiguous stock update

An order procedure calls sp_stockUpdate with parameters named @product and @stock, although the called procedure treats them as quantity and product ID. Renaming them to @OrderQty and @ProductID, and using sp_updateProductStockLevel, exposes the intended operation before a debugger traces the code. section 2.2

Listing 2.1 Returning a list of stored procedures
SELECT 
    name
FROM sys.procedures ;                      #1
  
SELECT 
    name
FROM sys.objects                           #2
WHERE type_desc = 'SQL_STORED_PROCEDURE' ; #2
  
SELECT 
    name
FROM sys.objects                           #3
WHERE type = 'P' ;                         #3

List stored procedures first when investigating a database; descriptive names should make this inventory a useful starting point rather than a guessing exercise. section 2.2

How 100 SQL Server Mistakes and How to Avoid Them covers it

How deep it goes
Explains naming through debugging and deployment scenarios, but defers a universal instance-name formula to organizational context.
Examples
Uses ambiguous stock-update procedures, procedure-listing SQL, and application-named SQL Server instances across two servers.
What it assumes
Assumes basic SQL fluency while teaching why readable object and instance names reduce investigation effort.
What you can do after
Apply it by choosing meaningful names that speed object discovery and remain understandable through operational change.
How it connects
Connects naming standards to coding standards, self-documenting code, stored procedures, and SQL Server instances.

Also explained in

Compare how 8 books explain naming standard →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of 100 SQL Server Mistakes and How to Avoid Them. The section links point to the parts of the book it draws on.