Home

Function and procedure names should comply with a naming convention

Description

    The "Function and Procedure Names Should Comply with a Naming Convention" rule states that all functions and procedures within a SQL Server database should be named according to a predetermined naming convention. This naming convention should be consistent across all databases and should be used to make it easier for developers and administrators to identify the purpose of a particular function or procedure. This naming convention should also be documented and used to ensure that all functions and procedures are consistently named.

Key Benefits

  • Improved readability: Using a naming convention helps make code more readable by making it easier to identify the purpose of a function or procedure.
  • Increased consistency: Adhering to a naming convention helps ensure that all functions and procedures have a consistent structure and format.
  • Reduced errors: By following a naming convention, it is easier to identify errors in code and can help reduce the amount of time spent debugging.
  • Simplified maintenance: Following a naming convention can make it easier to maintain code, as it is easier to identify what a function or procedure does.

 

Non-compliant Code Example

CREATE procedure [DATA].sp_GetFullname_  --Non compliant code (Procedure names is not comply with a naming convention)
@fname nvarchar(10),
@lname nvarchar(10) 
AS
BEGIN
    select [DATA].[GetFullName](@fname, @lname)
END
CREATE function [DATA].GetFullName_(@fname nvarchar(10), @lname nvarchar(10))  --Non compliant code (Function names is not comply with a naming convention)
returns nvarchar(20)
AS
BEGIN
    -- Check the employee
    RETURN (@fname + ', ' + @lname)
END
Visual Expert 2024
 VETSQLRULE35