Uncategorized

Get all Default Constraints for a table in SQL Server

The below snippet will list all check constraints for a given table in SQL Server:


SELECT
	DC.Name
FROM
	sys.schemas S
	INNER JOIN Sys.objects O
		on S.schema_id = O.schema_id
	INNER JOIN Sys.default_constraints DC
		ON O.object_id = dc.parent_object_id
WHERE
	S.name = 'SCHEMA_NAME'
AND
	O.name = 'TABLE_NAME'

Leave a Reply

Your email address will not be published. Required fields are marked *