Was this page helpful?
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Collapse the table of content
Expand the table of content
Expand Minimize

sp_helpconstraint (Transact-SQL)


Applies To: SQL Server 2014, SQL Server 2016 Preview

Returns a list of all constraint types, their user-defined or system-supplied name, the columns on which they have been defined, and the expression that defines the constraint (for DEFAULT and CHECK constraints only).

Applies to: SQL Server (SQL Server 2008 through current version), Azure SQL Database.

Topic link icon Transact-SQL Syntax Conventions

sp_helpconstraint [ @objname = ] 'table' 
     [ , [ @nomsg = ] 'no_message' ] 

[ @objname = ] 'table'

Is the table about which constraint information is returned. The table specified must be local to the current database. table is nvarchar(776), with no default.

[ @nomsg =] 'no_message'

Is an optional parameter that prints the table name. no_message is varchar(5), with a default of msg. nomsg suppresses the printing.

0 (success) or 1 (failure)

sp_helpconstraint displays a descending indexed column if it participated in primary keys. The descending indexed column will be listed in the result set with a minus sign (-) following its name. The default, an ascending indexed column, will be listed by its name alone.

Executing sp_help table reports all information about the specified table. To see only the constraint information, use sp_helpconstraint.

Requires membership in the public role.

The following example shows all constraints for the Product table.

USE AdventureWorks2012;
EXEC sp_helpconstraint 'Production.Product';
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2015 Microsoft