Results 1 to 4 of 4

Thread: on delete cascade & hierarchical table

  1. #1
    Join Date
    Apr 2006
    Posts
    178

    on delete cascade & hierarchical table

    for MS SQL 2000
    I am trying to do a hierarchical table and i want to add a ON DELETE CASCADE


    CREATE TABLE [dbo].[Users](
    [id_Users] [int] IDENTITY(1,1) NOT NULL PRIMARY KEY CLUSTERED,
    [id_UsersSup] [int] NULL,
    [Users] [nvarchar] (100) NOT NULL
    ) ON [PRIMARY]

    ALTER TABLE [dbo].[Users] ADD
    CONSTRAINT [FK_Users_Sup] FOREIGN KEY
    (
    [id_UsersSup]
    ) REFERENCES [Users] (
    [id_Users]
    )
    ON DELETE CASCADE


    but MS SQL refuse to create the foreign key
    even if there is 4 levels under the deleted id_Users I want to delete all the rows on all levels under

    thank you for helping

  2. #2
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    You are creating self referencing FK with CASCADE option, I don't think that is allowed.

  3. #3
    Join Date
    Apr 2006
    Posts
    178
    it seems that it is not

  4. #4
    Join Date
    Sep 2002
    Posts
    5,938
    Don't think sql allows it on single table.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •