To see constraint text , table_name and constraint_name in the same row.

SQL2k:

use purchase_stpl

select table_name,constraint_name,
constraint_text = 'sp_helptext ' + ''''+'dbo.'+constraint_name+''''
from information_schema.constraint_column_usage
where constraint_name like 'ck%'

table_name            constraint_name                   constraint_text      
str_item              CK_str_item                       sp_helptext 'dbo.CK_str_item'
str_pur_ord_mst       CK_str_pur_ord_mst                sp_helptext 'dbo.CK_str_pur_ord_mst'



sp_helptext 'dbo.CK_str_item'
text
(len(rtrim([item_code])) <> 0)

sp_helptext 'dbo.CK_str_pur_ord_mst'
text
(len([purchase_no]) = 8)

I want the first result like this

table_name            constraint_name                   constraint_text      
str_item              CK_str_item                       (len(rtrim([item_code])) <> 0)
str_pur_ord_mst       CK_str_pur_ord_mst                (len([purchase_no]) = 8)

If the solution needs store procedure, it has to be dynamic , starting with sp_ to
avoid creating the same in each database.
MateenAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

muzzy2003Commented:
SELECT TC.TABLE_NAME, TC.CONSTRAINT_NAME, CC.CHECK_CLAUSE
FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS TC INNER JOIN INFORMATION_SCHEMA.CHECK_CONSTRAINTS CC ON TC.CONSTRAINT_NAME = CC.CONSTRAINT_NAME

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.