Grant/revoke select, insert... across DBs

  • I have an instance of SQL2000 running on a server with 15 user DB's. I have a DB called DBA with proc/func ect.

    I want to be able to execute "grant select on gmi..deals to developers" from the DBA database running a procedure. I keep getting "You can only grant on the current database".

    Can this be done?

    Thanks,

    Joe

  • You'll have to loop through the dbs and execute once per db. Alternative would be to add the user to a server role.

    Andy

  • You could also create a script that checks for the existance of the table and does this then use sp_MSForEachDB to speed you along.

    "Don't roll your eyes at me. I will tape them in place." (Teacher on Boston Public)

  • Just a thought. If you are doing this anyway, I'd create a view in each DB that points to the other db. Easier than rewriting lots of queries of the db moves or you need another instance. Then use a role to grant permissions.

    Steve Jones

    steve@dkranch.net

  • Thank you for the help.

    I found the sp_msforeachdb in the object browser, but there is not any information from the "Help: online books".

    Can you recommend a good reference book? I am not looking for "How to", but something I can look up "sp_MSForEachDB" and get the information on it.

    Thanks again,

    Joe

  • Its undocumented, but this article by Brian should get you going:

    http://www.sqlservercentral.com/columnists/bknight/sp_msforeachdb.asp

    It will work, but I like Steve's suggestion of the view better.

    Andy

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

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