adding security to a Stored Procedure_

  • I have a server with multiple DB's but the same stored procedure has to exist in all databases and the the username of each db is = to the db name and the role is to execute only - is it posible to write a script to grant execute to each user per database instead to do it manually?

    Please help!

  • How about something as below?

    EXEC master..sp_MSForeachdb '

    USE [?]

    IF DB_ID(''?'') > 4 --dont do system dbs

    BEGIN

    EXEC sp_msforeachdb ''GRANT EXEC on myProc TO PUBLIC''

    END

    '

  • It did not work, maybe because I do not understand how is suppost to work, can you please explain?

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

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