Wednesday, June 29, 2011

How to get constraint of a table

How to get constraint of a table


You can get the constraints of a table from the database.

SELECT t.name AS table_name,o.name
AS
KeyName FROM
sys.Tables
t INNER JOIN
sys.objects
o ON t.OBJECT_ID
= o.parent_object_ID

Using above query you can get all the constraint of a particular table.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.