Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2004
    Location
    Arizona
    Posts
    75

    Unanswered: On Delete Trigger Issue

    I am trying to make this trigger work:

    CREATE TRIGGER [dbo].[COMPUTERS_BI_DELETE] ON [dbo].[COMPUTERS]
    WITH EXECUTE AS CALLER
    FOR DELETE
    AS
    BEGIN
    /* Trigger body */
    DELETE FROM IPS
    Where COMPUTERS_ITEM = (Select ITEM from Deleted);
    END


    But I get this error:

    Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= ... or when the subquery is used as an expression.

    I need to delete all rows where the key "ITEM" in the old COMPUTERS table matches the forigen key "COMPUTER_ITEMS" in the IPS table. I just simply want the value at the pointer of the deleted record with out having to run a subquery on the DELETED table.

    I have tried:

    ALTER TRIGGER [dbo].[COMPUTERS_BI_DELETE] ON [dbo].[COMPUTERS]
    WITH EXECUTE AS CALLER
    FOR DELETE
    AS
    BEGIN
    /* Trigger body */
    DELETE FROM IPS
    Where COMPUTERS_ITEM = Deleted.ITEM ;
    END

    but I get:

    The multi-part identifier "Deleted.ITEM" could not be bound.
    Last edited by AceOmega; 11-01-11 at 16:57.

  2. #2
    Join Date
    Sep 2001
    Location
    Chicago, Illinois, USA
    Posts
    601
    Have you tried . . .

    Code:
    delete  IPS
    from    IPS
    inner
    join    deleted on
                deleted.item=IPS.computers_item
    Ken

    Maverick Software Design

    (847) 864-3600 x2

  3. #3
    Join Date
    Apr 2004
    Location
    Arizona
    Posts
    75
    Yep that worked. Thank you.

Posting Permissions

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