After a bulk load with contraints check turned off I have some number of records in foreign key column to be removed because they violate constrains. DBCC indicates them nicely but is there a easy way to get violating value of this [colARef] = 'XXX' DBCC notation? I mean without parsing it, getting value to be able to look for primary key and then delete.
thanks
Asked
Active
Viewed 44 times
0

Zulu Z
- 1,103
- 5
- 14
- 27
1 Answers
1
Without looking at DBCC output at all, you can find the constraint violations like:
select *
from ReferencingTable t1
where not exists
(
select *
from ReferencedTable t2
where t1.ForeignKeyColumn = t2.Id
)

Andomar
- 232,371
- 49
- 380
- 404
-
Interesting thing though this query reported more violations then DBCC, is it possible DBCC doesn't report all? – Zulu Z Dec 13 '12 at 14:25