cascade delete


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: cascade delete

  1. #1
    Marian Guest

    cascade delete


    Hi! I must delete rows in cascade and I know that I can use triggers but I
    don't know how to built the triggers.
    Please, I need some help.
    Thanks in advance!!!
    Marian

  2. #2
    Dennis Guest

    Re: cascade delete


    "Marian" <mrsebedio@hispanoamericana.com.ar> wrote:
    >
    >Hi! I must delete rows in cascade and I know that I can use triggers but

    I
    >don't know how to built the triggers.
    >Please, I need some help.
    >Thanks in advance!!!
    >Marian


    What DBMS and version are you using?

    Dennis

  3. #3
    Marian Guest

    Re: cascade delete




    "Dennis" <DennisRehm@AppliedComputing.net> wrote:
    >
    >"Marian" <mrsebedio@hispanoamericana.com.ar> wrote:
    >>
    >>Hi! I must delete rows in cascade and I know that I can use triggers but

    >I
    >>don't know how to built the triggers.
    >>Please, I need some help.
    >>Thanks in advance!!!
    >>Marian

    >
    >What DBMS and version are you using?
    >
    >Dennis

    SQL Server 7.0

  4. #4
    Dennis Guest

    Re: cascade delete


    "Marian" <mrsebedio@hispanoamericana.com.ar> wrote:
    >
    >
    >
    >"Dennis" <DennisRehm@AppliedComputing.net> wrote:
    >>
    >>"Marian" <mrsebedio@hispanoamericana.com.ar> wrote:
    >>>
    >>>Hi! I must delete rows in cascade and I know that I can use triggers but

    >>I
    >>>don't know how to built the triggers.
    >>>Please, I need some help.
    >>>Thanks in advance!!!
    >>>Marian

    >>
    >>What DBMS and version are you using?
    >>
    >>Dennis

    >SQL Server 7.0


    When you move to SQL Server 2000, you will be able to do cascading deletes
    easily. In SQL Server 7.0-

    Do not define a foreign key relationship between the table where the delete
    occurs and the table where the delete will cascade. The foreign key constraint
    will generate an error before the trigger can fire. If you want referential
    integrity, it will need to be in the trigger, too.

    Look at Books Online under Trigger - Create. It will explain the syntax.
    It will be something like:

    CREATE TRIGGER triggername ON table_a
    FOR DELETE
    AS
    delete from table_b
    from deleted
    where table_b.key = deleted.key

    Dennis

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center