Take a look at Sebastian Meiner's blog post: https://sqlity.net/en/2584/script-database-permissions/
SQL Server how to synch Users and security permission with User Database Role ?
Hello, I have 2 user DBs and Roles with same names on each on separate SQL Servers i.e.
- Server_Dev.[Orders] DB [Sales] Role
- Server_Prod.[Orders] DB [Sales] Role
What I'm stuck at is that the [Sales] Role Users & security permissions within each are different & not in synch.
Basically I'd like to transfer all of the missing Users & their security permissions from Source Server_Prod.[Orders] DB [Sales] Role that's missing in corresponding Target Server_Dev.[Orders] DB [Sales] Role
Is there a way to do this?
(I don't have enough disk space to simply restore over entire Target Server_Dev.[Orders] DB from Source Server_Prod.[Orders] DB being the easiest method.)
Thanks in advance.
SQL Server | Other
-
Erland Sommarskog 121.8K Reputation points MVP Volunteer Moderator
2023-03-19T09:36:31.8+00:00
2 additional answers
Sort by: Most helpful
-
Bjoern Peters 8,921 Reputation points
2023-03-20T02:13:49.01+00:00 Hi techsearch,
Welcome to Q&A Forum; this is a great place to get support, answers, and tips.
Thank you for posting your query; I'll be more than glad to help you out.
Maybe you find your own solution in a combination of commands from the PowerShell module dbatools
https://dbatools.io/commands/#Login
I hope my answer is helpful to you,
Your
Bjoern Peters
If the reply was helpful, please upvote and/or accept it as an answer, as this helps others in the community with similar questions. Thanks!
-
Seeya Xi-MSFT 16,586 Reputation points
2023-03-20T08:46:22.9066667+00:00 Hi @techresearch7777777 ,
Please refer to this MS document:
As for transferring all of the missing Users & their security permissions, please refer to this similar thread:
Best regards,
Seeya
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".