Skip to content

Latest commit

 

History

History
58 lines (50 loc) · 2.7 KB

sys-default-constraints-transact-sql.md

File metadata and controls

58 lines (50 loc) · 2.7 KB
title description author ms.author ms.date ms.service ms.subservice ms.topic ms.custom f1_keywords helpviewer_keywords dev_langs monikerRange
sys.default_constraints (Transact-SQL)
sys.default_constraints (Transact-SQL)
VanMSFT
vanto
03/15/2017
sql
system-objects
reference
ignite-2024
sys.default_constraints
sys.default_constraints_TSQL
default_constraints
default_constraints_TSQL
sys.default_constraints catalog view
TSQL
>=aps-pdw-2016 || =azuresqldb-current || =azure-sqldw-latest || >=sql-server-2016 || >=sql-server-linux-2017 || =azuresqldb-mi-current || =fabric

sys.default_constraints (Transact-SQL)

[!INCLUDE sql-asdb-asdbmi-asa-pdw-fabricdw-fabric]

Contains a row for each object that is a default definition (created as part of a CREATE TABLE or ALTER TABLE statement instead of a CREATE DEFAULT statement), with sys.objects.type = D.

Column name Data type Description
<Columns inherited from sys.objects> For a list of columns that this view inherits, see sys.objects (Transact-SQL).
parent_column_id int ID of the column in parent_object_id to which this default belongs.
definition nvarchar(max) SQL expression that defines this default.
is_system_named bit 1 = Name was generated by system.

0 = Name was supplied by the user.

Permissions

[!INCLUDEssCatViewPerm] For more information, see Metadata Visibility Configuration.

Examples

The following example returns the definition of the DEFAULT constraint that is applied to the VacationHours column of the HumanResources.Employee table.

USE AdventureWorks2022;  
GO  
SELECT d.definition   
FROM sys.default_constraints AS d  
INNER JOIN sys.columns AS c  
ON d.parent_object_id = c.object_id
AND d.parent_column_id = c.column_id  
WHERE d.parent_object_id = OBJECT_ID(N'HumanResources.Employee', N'U')  
AND c.name = 'VacationHours';  

See Also

Object Catalog Views (Transact-SQL)
Catalog Views (Transact-SQL)
Querying the SQL Server System Catalog FAQ