DBCC CHECKCONSTRAINTS (FK_EmployeeID)
-- checks an individual constraint
--Returns all the rows that has wrongly inserted RI records with respect
to that particular constraint.
DBCC CHECKCONSTRAINTS WITH
ALL_CONSTRAINTS
-- checks all constraints in the database
--Returns all the constraint if it has violation only.
--To get all the tables and keys information
--To get all the tables and keys information
SELECT
TableName = t.Name,
dc.Name
FROM sys.tables t
INNER JOIN sys.foreign_keys dc
ON t.object_id = dc.parent_object_id
--where dc.is_not_trusted=1
No comments:
Post a Comment