Partilhar via


sp_helpconstraint (Transact-SQL)

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).

Topic link iconTransact-SQL Syntax Conventions

Syntax

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

Arguments

  • [ @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.

Return Code Values

0 (success) or 1 (failure)

Result Sets

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.

Remarks

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

Permissions

Requires membership in the public role.

Examples

The following example shows all constraints for the Product table.

USE AdventureWorks;
GO
EXEC sp_helpconstraint 'Production.Product';

See Also

Reference

Database Engine Stored Procedures (Transact-SQL)
ALTER TABLE (Transact-SQL)
CREATE TABLE (Transact-SQL)
sp_help (Transact-SQL)
System Stored Procedures (Transact-SQL)
sys.key_constraints (Transact-SQL)
sys.check_constraints (Transact-SQL)
sys.default_constraints (Transact-SQL)

Help and Information

Getting SQL Server 2005 Assistance

Change History

Release History

14 April 2006

Changed content:
  • Removed note that stated this stored procedure is being deprecated.