문제

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

도움이 되었습니까?

해결책

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
        )
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top