A: 

You can accomplish it with a "DELETE TRIGGER" - just use it to delete any rows that have matching parents. It's essentially the same thing a cascade-delete would do.

CREATE TRIGGER t_Codings_delete
            ON Codings
         AFTER DELETE
AS
BEGIN

    DELETE Codings
      FROM Codings c
      JOIN DELETED d -- Virtual table containing rows you just deleted
        ON c.ParentId = d.Id

END
rwmnau
@rwmnau : Thank you , But i supposed i could do it via relation , There isn't any way to that without trigger ?
Mostafa
@Mostafa - you could probably use an integrity constraint and cascading deletes to do it, but I'm always wary of cascading deletes for some reason. The trigger does the exact same thing, and I like it because it's more obvious - somebody wondering why rows have disappeared from the table may not think to look for a constraint with a cascading delete, since they're rare, and they may look for a trigger. Functionally though, you're right - there's no difference.
rwmnau
+1  A: 

Maybe you have to define a index on the ParentID column first. You can't put constraints on columns that aren't indexed.

Lex
@Lex , No dear , There is just one index and that's clustered on primary Key .
Mostafa
Yeah, but you will have to define another index on the parentID column before you can define relations on it.
Lex
+1  A: 

I always script for solutions to this, IE in the application search for the ID, then delete where all parent IDs = ID, then delete the parent record.

Tom Gullen
A: 

How about an OR clause?

Delete From TableName
Where ID = 4 OR ParentId = 4
G Mastros
A: 

I don't think you can have cascading deletes on a self-refrencing table. You can probably do it with a join.

Delete from codings
inner join codings2 on codings.id = codings2.parentid
where codings.id = myid

Note not tested.

Gratzy