Assert verifies that table has default constraint with a given name and that this constrain have expected value. Fail when default constraint is not found or when default constraint value does not match expected value.

Arguments

  • v_DefaultConstrant – Default Constraint name, SYSNAME
  • v_TableName – Table Name. Supports four part object name server.database.schema.object, SYSNAME
  • v_DefaultConstrantDefinition – SQL expression that defines default constraint. NVARCHAR(MAX)
  • v_UserMessage – message to report when assertion fails, NVARCHAR(MAX)

NOTE: Sample default constraint values

  • Numbers: ((0)), ((1.25))
  • String values: ('='), ('Disabled')
  • Functions: (getdate()), (newid()), (app_name()), (db_name()), (suser_sname())

 

Examples

SQL Server 

EXEC DBTD_ASSERT_DEFAULT_CONSTRAINT    
    'DF_MyTable_AmIHidden'
, 
    'MyDatabase.MySchema.MyTable',
    '((0))', 
    'Invalid default value for AmIHidden column';

 
See Also