How to delete records from two tables. There is relationship between two tables.

It's working in MySQL but not in SQL-Server.

Showing Answers 1 - 10 of 10 Answers

when  ON DELETE CASCADE  is mention in the table while creating them, then
 if we use delete command in one table then it affects the other table also,

i think this is correct,
u try it out.

Use a procedure which will delete record from child table first and then it will delete the same record from parent table

Same thing can be achieved using cascade delete and cascade update, this feature was not there in sql server 7.0

  Was this answer useful?  Yes


  For deleting the records from the relational tables there are 4 options available. These options can be used when you create the tables then you have to use these options and create tables and provide relationships. those options are

1. On delete no action
        we have to set the column as on delete no action then there is no action should perform for deleting the record from the child table.
2. On delete cascade
        we have to set the column as on delete cascade then when ever you have to delete the child record then automatically corresponding parent record will be deleted.
3. On delete set null
        we have to set the column as on delete set null then when ever you have to delete the record from the child table then corresponding parent record values will be set as null.
4. On delete set default
         we have to set the column as on delete set default then when ever you have to delete the record from the child table then corresponding parent record values will be set as default values

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions