Delete data with foreign key in SQL Server table

后端 未结 9 630
青春惊慌失措
青春惊慌失措 2020-12-12 20:32

I\'m going to delete data in an SQL Server table (parent) which has a relationship with another table (child).
I tried the basic Delete query. But it isn\'t working (and

9条回答
  •  猫巷女王i
    2020-12-12 21:14

    To delete data from the tables having relationship of parent_child, First you have to delete the data from the child table by mentioning join then simply delete the data from the parent table, example is given below:

    DELETE ChildTable
    FROM ChildTable inner join ChildTable on PParentTable.ID=ChildTable.ParentTableID
    WHERE  
    
    
    DELETE  ParentTable
    WHERE 
    

提交回复
热议问题