Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 HOW TO DELETE ROW FROM MULTIPLE DEPENDENT TABLEW W

Author  Topic 

teamjai
Yak Posting Veteran

52 Posts

Posted - 2011-12-29 : 00:12:16
I'm getting the following error when trying to run a delete statement
The DELETE statement conflicted with the REFERENCE constraint "FK_Table2_Table1". The conflict occurred in database "DBTEST", table "dbo.Table2", column 'ID'

Table1:Name, Id(PrimaryKey)
Table2:EName, Id(ForeignKey)

How do I delete from multiple tables .
pls

manju3606
Yak Posting Veteran

78 Posts

Posted - 2011-12-29 : 00:22:43

you have to delete all child tables one by one witch have relationship with table1.

Manju
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-12-29 : 00:33:21
see this to get the ordering of tables for delete

http://visakhm.blogspot.com/2011/11/recursive-delete-from-parent-child.html

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

teamjai
Yak Posting Veteran

52 Posts

Posted - 2011-12-29 : 00:54:42
thanks all

Go to Top of Page
   

- Advertisement -