2

New to SQL, first time poster. I searched a bit for what I was looking for. Couldn't locate. I appreciate your help...I'm still learning terms and commands.

Consider this:

  • User XYZ has access to BLAH table with GRANT permission to EXECUTE
  • User ABC has access to OKAY table with GRANT permission to SELECT

Question(s):

Is there an SQL query I can write that will take all the Securables of user ABC and add them into user XYZ? If yes, is there any reason why the same query would not work on Roles?

The end result with this scenario would look like this...

  • User XYZ has access to BLAH table with GRANT permission to EXECUTE
  • User XYZ has access to OKAY table with GRANT permission to SELECT
  • User ABC has access to OKAY table with GRANT permission to SELECT

Things of Note:

This is a very small example. I realize I could just manually add what I am talking about in this scenario.

I was toying around with the ALTER USER (or ALTER ROLE) statements. I couldn't find the appropriate syntax. When I would do an internet search I could never seem to locate what I was looking for. I blame it on my newbie status. :)

migrated from stackoverflow.com Jun 9 '15 at 6:08

This question came from our site for professional and enthusiast programmers.

  • You've tagged your question with two different DBMSes, is this question for both? – GolezTrol Jun 8 '15 at 20:27
  • 2
    A similar question has been asked before on Server Fault. The answers seem to suggest that there is no way to do it as you asked, but you can export the grants using a script and use that as a base to generate a new list of grant statements from. – GolezTrol Jun 8 '15 at 20:28
  • Sorry, was just for sql-server. – IrishHound Jun 8 '15 at 20:38
  • Thanks for the info Golez. I'll take a look at the link you provided for the script info. Appreciated. – IrishHound Jun 8 '15 at 20:39
  • You're welcome, but the link is for MySQL, so it may not be helpful after all. – GolezTrol Jun 8 '15 at 20:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy