Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Cascading Delete

Cascading Delete

Scheduled Pinned Locked Moved Database
databasequestionmysqlsql-serversysadmin
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    eggie5
    wrote on last edited by
    #1

    I have an ms sql database that has foreign key relationships and until today I hadn't mapped those out via sql server, they were just on paper. So for example, I have a Company with many People. Before, when I deleted a Company, it's many people were orphaned. Now, since I've mapped the relationship for the sql server, when I try to delete a Company, I get an error. I think in mysql talk this is called a cascading delete. How do I do this with ms sql?

    /\ |_ E X E GG

    A 1 Reply Last reply
    0
    • E eggie5

      I have an ms sql database that has foreign key relationships and until today I hadn't mapped those out via sql server, they were just on paper. So for example, I have a Company with many People. Before, when I deleted a Company, it's many people were orphaned. Now, since I've mapped the relationship for the sql server, when I try to delete a Company, I get an error. I think in mysql talk this is called a cascading delete. How do I do this with ms sql?

      /\ |_ E X E GG

      A Offline
      A Offline
      andyharman
      wrote on last edited by
      #2

      Which database product are you using? With most databases you just need to add ON DELETE CASCADE to your foreign-key definition.

      If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message".

      E 1 Reply Last reply
      0
      • A andyharman

        Which database product are you using? With most databases you just need to add ON DELETE CASCADE to your foreign-key definition.

        If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message".

        E Offline
        E Offline
        eggie5
        wrote on last edited by
        #3

        I'm using sql server 2000, but I just found the property for cascading deletes under the relationships menu on my table.

        /\ |_ E X E GG

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups