Reports information about integrity constraints used in the specified tables.


sp_helpconstraint [objname][, detail] 




There are additional considerations when using sp_helpconstraint:
  • sp_helpconstraint truncates foreign keys and reference keys to 30 characters.

  • sp_helpconstraint prints the name and definition of the integrity constraint, and the number of references used by the table. The detail option returns information about the constraint’s user or error messages.

  • sp_helpconstraint displays sharable inline defaults similarily to how it displays regular inline defaults.

  • Running sp_helpconstraint with no parameters lists all the tables containing references in the current database, and displays the total number of references in each table. sp_helpconstraint lists the tables in descending order, based on the number of references in each table.

  • sp_helpconstraint reports only the integrity constraint information about a table (defined by a create table or alter table statement). It does not report information about rules, triggers, or indexes created using the create index statement. Use sp_help to see information about rules, triggers, and indexes for a table.

  • For constraints that do not have user-defined messages, the SAP ASE server reports the system error message associated with the constraint. Query sysmessages to obtain the actual text of that error message.

  • You can use sp_helpconstraint only for tables in the current database.

  • If a query exceeds the configured number of auxiliary scan descriptors, the SAP ASE server returns an error message. You can use sp_helpconstraint to determine the necessary number of scan descriptors. See the System Administration Guide or more information on the number of aux scan descriptors configuration parameter.

  • A system security officer can prevent the source text of constraint definitions from being displayed to most users who execute sp_helpconstraint. To restrict select permission on the text column of the syscomments table to the object owner or a system administrator, use sp_configure to set the select on syscomments.text column parameter to 0. This restriction is required to run the SAP ASE server in the evaluated configuration. See the System Administration Guide for more information about the evaluated configuration.

See alsoalter table, create table in Reference Manual: Commands .


Any user can execute sp_helpconstraint. Permission checks do not differ based on the granular permissions settings.


Values in event and extrainfo columns from the sysaudits table are:



Audit option


Command or access audited

Execution of a procedure

Information in extrainfo
  • Roles – Current active roles

  • Keywords or options – NULL

  • Previous value – NULL

  • Current value – NULL

  • Other information – All input parameters

  • Proxy information – Original login name, if set proxy in effect

Related reference