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. Web Development
  3. ASP.NET
  4. trigger

trigger

Scheduled Pinned Locked Moved ASP.NET
databasetutorialquestion
3 Posts 3 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.
  • X Offline
    X Offline
    x trate
    wrote on last edited by
    #1

    I have two tables And i want to create a trigger so that when i delete a row from table1 the rows related to it from table2 should be deleted two. can you give some directions?(fot what table should i write the trigger?). Perhaps some one has a link with an example or something. Thank you!

    C D 2 Replies Last reply
    0
    • X x trate

      I have two tables And i want to create a trigger so that when i delete a row from table1 the rows related to it from table2 should be deleted two. can you give some directions?(fot what table should i write the trigger?). Perhaps some one has a link with an example or something. Thank you!

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Try the SQL forums. I'd do it as a stored procedure, that takes the data and deletes the right values from both rows, starting with the one that has the contraint that would otherwise be broken. Assuming you have added the necessary constraints so that users can't delete one table's data and orphan the other. Christian Graus - Microsoft MVP - C++

      1 Reply Last reply
      0
      • X x trate

        I have two tables And i want to create a trigger so that when i delete a row from table1 the rows related to it from table2 should be deleted two. can you give some directions?(fot what table should i write the trigger?). Perhaps some one has a link with an example or something. Thank you!

        D Offline
        D Offline
        DELETEUSER
        wrote on last edited by
        #3

        One table has to have a primary key which is a primary key or a foreign key of the second table. Your trigger should be such that upon the primary key tuple deletion from table 1 it also deletes assosicated tuples from table2 using primary key - foreign key relation. This will help you prevent dangling tuples. ---------- Venus Patel http://patelsinc.blogspot.com/ A student knows little about a lot. A professor knows a lot about little. I know everything about nothing.

        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