The output of the sp_helpconstraint system stored procedure consists of three result sets, so you can't insert the output into a temporary table.Therefore, I created the sp_showConstraints stored procedure as a short and simple alternative to using sp_helpconstraint when I need to find all the constraints for a table.
The sp_showConstraints store procedure analyzes all constraints and summarizes them in a short result set that consists of the constraint name, ID, type, and level. All information is decoded out of the sysconstraints system table.
Listing 1 shows the code for sp_show-Constraints. To use this stored procedure, you call it with code such as
USE pubs GO EXEC sp_showConstraints 'Authors'
Table 1 shows sample results from sp_showConstraints.
I tested this procedure in SQL Server 2005.
— Eli Leiba