USE AdventureWorks;
GO
SELECT OBJECT_NAME(OBJECT_ID) AS NameofConstraint,
SCHEMA_NAME(schema_id) AS SchemaName,
OBJECT_NAME(parent_object_id) AS TableName,
type_desc AS ConstraintType
FROM sys.objects
WHERE type_desc LIKE '%CONSTRAINT'
GO
2.
Select * from INFORMATION_SCHEMA.CONSTRAINT_Table_Usage
Wednesday, August 10, 2011
List All The Constraint of Database – Find Primary Key and Foreign Key Constraint in Database
Following script are very useful to know all the constraint in the database. I use this many times to check the foreign key and primary key constraint in database. This is simple but useful script from my personal archive.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment