October 3, 2011 at 9:00 am
Hello all,
I have an INSERT INTO ... SELECT ... statement that should insert approx 5000 rows. When I run the statement, it throws a FK violation error. I understand what this means, etc. but my question is -- is there a way to determine what specific data caused the violation? I'd like to have it return some data to be able to uniquely identify the problematic data.
Let me know if you need more information.
Thanks,
Brett
October 3, 2011 at 9:13 am
The error should tell you what Fk is violated.
With that you can do a select from (what you insert) where not exists (match to fk table)
October 3, 2011 at 9:15 am
Yes, the error gives the table / FK info. I have a select that does this but was just wondering if there was an easier way to get this info.
Thanks,
Brett
October 3, 2011 at 9:19 am
Nope.
And it doesn't really get easier than copy / paste the select statement and simply add
where not exists (SELECT * FROM dbo.fk where fk.a = base.a)
October 3, 2011 at 9:21 am
OK. Thanks. That's what I thought -- just confirming.
Thanks,
Brett
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply