Rights to execute stored procedure

  • Hi,

    I have this stored procedure:

    create procedure UpdateAut (@TIPO as varchar(10),@OBS as varchar(20))

    as

    begin

    declare @erro as integer

    begin transaction

    update consulta_contribuintes set tipo =@tipo,obs=@obs,dtaupd=getdate()

    set @erro =@@error

    if @erro =0

    begin

    commit transaction

    insert into procedimentos_executados values (21)

    end

    else

    rollback transaction

    end

    I want that a user (SQL User) can execute the stored procedure, so i will give him the right to execute the procedure.

    Inside the procedure i insert and update values in two tables:

    consulta_contribuintes

    procedimentos_executados

    This users needs rights to in this two tables? or only needs the right to execute the procedure?

    Thank you

  • Should only need execute rights on the stored procedure. There may be exceptions to that, but usuallly only if the tables in question on in another database.

  • hum???

    How is that?

    If a user as rights to execute the stored procedure but do not have permissions on the tables inside the stored procedure how can the procedure run if it runs in the context of the user?

  • It is one aspect of security. If you only grant users access to the views and stored procedures, they don't require access to the underlying tables. It is a means of layering security.

    Also, by using views and stored procedures to provide access to the underlying tables, you hide the actual schema of your database. If future changes are required to add functionality, as long as the output from the views and stored procedures remains the same, the users never have to know that the schema changed.

  • ok, thank you very much.

    So what is the "EXECUTE AS" for?

  • river1 (3/24/2010)


    ok, thank you very much.

    So what is the "EXECUTE AS" for?

    to execute as another database user that is not linked to a server level login

    -----------------------------------------------------------------------------------------------------------

    "Ya can't make an omelette without breaking just a few eggs" 😉

Viewing 6 posts - 1 through 5 (of 5 total)

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