Monday, March 12, 2012

How to list the names of check constraint of a table and how to show it's content?

How to list the names of check constraint of a table?
How to show the content of a check constraint?
Thanks
--Frank, SQL2005This should give you a start:
SELECT * FROM sys.check_constraints
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Frank Lee" <Reply@.to.newsgroup> wrote in message news:O5k41PKKGHA.3944@.tk2msftngp13.phx.gb
l...
> How to list the names of check constraint of a table?
> How to show the content of a check constraint?
> Thanks
> --Frank, SQL2005
>|||Hi, Frank
This also works in SQL 2000 (as well as SQL 2005):
SELECT CC.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
WHERE TABLE_NAME='YourTable' AND CONSTRAINT_TYPE='CHECK'
Razvan

No comments:

Post a Comment