sys.sp_helpconstraint
sphelpconstraint returns a list of all constraint types and their information.
What changes
- Input
- Not stated in the Microsoft summary.
- Output or change
- Not stated in the Microsoft summary.
Syntax at a glance
sys.sp_helpconstraint
[ @objname = ] N'objname'
[ , [ @nomsg = ] 'nomsg' ]
[ ; ]
Work example
sphelpconstraint returns a list of all constraint types and their information.
Write a proposed call on paper. Name the target, required permission, expected change, and recovery step before any lab use.
Check your work Inspects constraints on the first visible user table in the current database. The SELECT reads metadata and the procedure call is conditional.
Practice SQL
Open in SQL FlowOpen the SQL for a walkthrough. Run the example in SQL Server to check its result.
DECLARE @object_name nvarchar(517); SELECT TOP (1) @object_name = QUOTENAME(s.name) + N'.' + QUOTENAME(t.name) FROM sys.tables AS t JOIN sys.schemas AS s ON s.schema_id = t.schema_id WHERE t.is_ms_shipped = 0 ORDER BY s.name, t.name; IF @object_name IS NOT NULL EXEC sys.sp_helpconstraint @objname = @object_name; ELSE SELECT N'No visible user table in the current database.' AS check_message;
Open Microsoft Learn for full syntax, permissions, and details for your version.