Click or drag to resize

SA0062B : Check function names used in CREATE FUNCTION statements for following specified naming convention

The topic describes the SA0062B analysis rule.

Message

Check function names used in CREATE FUNCTION statements for following specified naming convention

Description

The rule checks the function name in CREATE FUNCTION statements.

Separate name patterns are available for each function types:

- Scalar Function

- Aggregate Function

- Table-Valued Function

- Partition Function

Regular expression patterns can be used, but the pattern must be prefixed with 'regexp:' string in order to be used as a matching regular expression.

Scope

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

Parameters
NameDescriptionDefault Value
ScalarFunctionNamePattern

Scalar function name pattern.

regexp:ufn[A-Z][A-Za-z1-9_]+

ScalarFunctionSchemaQualifiedNamePattern

Scalar function schema qualified name pattern.

-

TableValuedFunctionNamePattern

Table-valued function name pattern.

regexp:ufn[A-Z][A-Za-z1-9_]+

TableValuedFunctionSchemaQualifiedNamePattern

Table-valued function schema qualified name pattern.

-

AggregateFunctionNamePattern

Aggregate function name pattern.

regexp:ufn[A-Z][A-Za-z1-9_]+

AggregateFunctionSchemaQualifiedNamePattern

Aggregate function schema qualified name pattern.

-

PartitionFunctionNamePattern

Partition function name pattern.

regexp:[A-Z][A-Za-z1-9_]+PFN

Remarks

The rule does not need Analysis Context or SQL Connection.

Categories

Naming Rules

Additional Information

There is no additional info for this rule.

Example Test Script
SQL
 1CREATE FUNCTION Sales.ufn_SalesByStore (@storeid int)
 2RETURNS TABLE
 3AS
 4RETURN 
 5(
 6    SELECT P.ProductID, P.Name, SUM(SD.LineTotal) AS 'YTD Total'
 7    FROM Production.Product AS P 
 8      JOIN Sales.SalesOrderDetail AS SD ON SD.ProductID = P.ProductID
 9      JOIN Sales.SalesOrderHeader AS SH ON SH.SalesOrderID = SD.SalesOrderID
10    WHERE SH.CustomerID = @storeid
11    GROUP BY P.ProductID, P.Name
12);

Analysis Results

 MessageLineColumn
1SA0062B : The function [Sales].[ufn_SalesByStore] does not match the naming convention. The expected key name is [tvfn_[A-Z][A-Za-z1-9_]+].122
See Also

Other Resources