Jump to content

Calling Sql Experts......help


Recommended Posts

Posted

i have 2 tables. emp and extemp.
emp lo col name id and extemp lo col name emp_id but both values are same.
ippudu naaku ee rendu tables lo unna row ni oke sari delete cheyadaniki query kavali.

for ex : emp.id = 1111 aithe extemp table lo unna emp_id kuda 1111

now how to delete this row.......plz help bayyas........



[b] [url="http://forum.springsource.org/showthread.php?102729-Cannot-delete-or-update-a-parent-row-a-foreign-key-constraint-fails"]Cannot delete or update a parent row: a foreign key constraint fails[/url] [/b]

ane error vasthundi... &*B@ &*B@ sFun_duh2

Posted

delete from [color=#282828][font=helvetica, arial, sans-serif][size=4]extemp where [/size][/font][/color][color=#282828][font=helvetica, arial, sans-serif] emp_id = @id[/font][/color]

delete from [color=#282828][font=helvetica, arial, sans-serif]emp[/font][/color][color=#282828][font=helvetica, arial, sans-serif][size=4] where [/size][/font][/color][color=#282828][font=helvetica, arial, sans-serif] id = @id[/font][/color]

Posted

1)First drop the constraint in child table the you can delete records in both tables at once

2 )first delete the record in child table and then in parent

delete from child where x = x
Go

delete from paretn where x=x
Go

×
×
  • Create New...