Insert without permissions from within a trigger

  • Supose you have tables [TBL A] and [TBL B]

    CREATE TABLE [TBL A] (

    [FIELD_A] [char] (10) COLLATE Latin1_General_CI_AS NULL

    ) ON [PRIMARY]

    GO

    CREATE TABLE [TBL B] (

    [FIELD_B] [char] (10) COLLATE Latin1_General_CI_AS NULL

    ) ON [PRIMARY]

    GO

    [TBL A] has the following trigger:

    CREATE TRIGGER ITRIGGER ON [dbo].[TBL A]

    FOR INSERT

    AS

    DECLARE @F_A AS CHAR(10)

    SELECT @F_A = (SELECT FIELD_A FROM INSERTED)

    INSERT INTO [TBL B] (FIELD_B) VALUES (@F_A)

    User USR_A has public database role permissions and select, insert, update, delete permissions on [TBL A] and no permissions on [TBL B].

    For what reason when USR_A inserts a record on [TBL A] a record is inserted also on [TBL B] even he has no permissions at all on [TBL B]?

    Thanks for your help

    João Crespo

  • Simple answer: ownership chaining. 🙂

    K. Brian Kelley
    @kbriankelley

  • K. Brian Kelley (5/20/2011)


    Simple answer: ownership chaining. 🙂

    Thanks Brian,

    Very obviously, but I didn't remember. :blush:

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply