How to Delete all data from a table which contain self referencing foreign key

Posted by Shantanu Gupta on Stack Overflow See other posts from Stack Overflow or by Shantanu Gupta
Published on 2010-03-20T13:22:00Z Indexed on 2010/03/20 13:31 UTC
Read the original article Hit count: 335

Filed under:
|
|
|

I have a table which has employee relationship defined within itself. i.e.

EmpID   Name  SeniorId
-----------------------
1         A      NULL
2         B       1
3         C       1
4         D       3

and so on...

Where Senior ID is a foreign key whose primary key table is same with refrence column EmpId I want to clear all rows from this table without removing any constraint. How can i do this?

Deletion need to be performed like this 4, 3 , 2 , 1

How can I do this

© Stack Overflow or respective owner

Related posts about database

Related posts about sql