Microsoft Default Constraints Naming Convention

Have you ever wondered how Microsoft comes up with Default Constraint names?

The name consists of several parts separated by _

  1. DF : Default Constraint
  2. sysmail_p: First 9 characters of the table name
  3. last_ : First 5 characters of the column name
  4. Binary value of the columns’ default_object_id

    | sysmail_profile | last_mod_datetime | 622625261

DF_ | _sysmail_p_     | _last__           | _251C81ED

12_ | _123456789_     | _12345_           | _…..

The T-SQL formula to work out the binary value is
 

SELECT
  [name] AS column_name
, CAST(default_object_id AS varbinary(MAX)) AS binary_value
FROM sys.columns
WHERE 1=1
AND OBJECT_ID = OBJECT_ID('sysmail_profile')
AND default_object_id <> 0;

 

Leave a Reply