title | description | author | ms.author | ms.reviewer | ms.date | ms.service | ms.subservice | ms.topic | f1_keywords | helpviewer_keywords | dev_langs | monikerRange | ||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
sp_helpconstraint (Transact-SQL) |
sp_helpconstraint returns a list of all constraint types and their information. |
markingmyname |
maghan |
randolphwest |
05/14/2024 |
sql |
system-objects |
reference |
|
|
|
=azuresqldb-current || >=sql-server-2016 || >=sql-server-linux-2017 || =azuresqldb-mi-current |
[!INCLUDE SQL Server SQL MI]
Returns a list of all constraint types, their user-defined or system-supplied name, the columns on which they're defined, and the expression that defines the constraint (for DEFAULT
and CHECK
constraints only).
:::image type="icon" source="../../includes/media/topic-link-icon.svg" border="false"::: Transact-SQL syntax conventions
sp_helpconstraint
[ @objname = ] N'objname'
[ , [ @nomsg = ] 'nomsg' ]
[ ; ]
Specifies the table for which the constraint information is returned. @objname is nvarchar(776), with no default. The table specified must be local to the current database.
An optional parameter that prints the table name. @nomsg 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 is listed in the result set with a minus sign (-
) following its name. The default, an ascending indexed column, is 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.
[!INCLUDE article-uses-adventureworks]
The following example shows all constraints for the Product.Product
table.
USE AdventureWorks2022;
GO
EXEC sp_helpconstraint 'Production.Product';