DBCC will not verify that all detail rows have a corresponding master record. It's up to your application to maintain that relationship. DBCC is used to verify the internal integrity of the database. (It is also the dumping ground for a variety of functionality).
You can create Foreign Key constraints and have the database engine do the checking for you.
CREATE TABLE master (pk int IDENTITY(1,1) ... )
CREATE TABLE detail (pk int IDENTITY(1,1), fk int REFERENCES master(pk) ...)
Here the FK constraint will verify that each row in detail has a corresponding parent in master. If not, an exception will be thrown. The constraint will also verify that no row in child exist before allowing the parent row in master to be deleted. If child rows do exist, an exception will be thrown.
-Mike
>The DBCC is use to check the consistency and integrity of database. It checks physical and logican consistency.
>
>We are using SQL6.5. We used DBCC CHECKDB for checking database and didn't get any errors. But some users found some orphan record (no parent) in some tables.
>Does DBCC check this?
>How can we check this?
>
>What does DBCC check or not check?
>
>
>
>Thanks
>
>
>Jim