How can this SQL statement throw the following exception? -


how can statement:

delete passage passageid not in (     select passageid preendedpassages_passages     union select frompassageid severalvisit     union select topassageid severalvisit     union select registerpassageid stationobjects registerpassageid not null     union select beginpassageid stationobjects beginpassageid not null     union select endpassageid stationobjects endpassageid not null ) 

throw exception?

the delete statement conflicted foreign key constraint "fk_statobj_begpasid". conflict occurred in database "db.mdf", table "dbo.stationobjects", column 'beginpassageid'. 

i have no clue, happened. beginpassageid foreign key on passageid.

edit: consider not in. want delete passages don't exist in 1 of related tables. works, happened once.

thank you.

it means passage parent table. , stationobjects child table. trying remove passageid passage table present in stationobjects table well.

first try remove passageid stationobjects , can run delete statement.

alternate approach cascade delete, if db supports that.


Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -