How to script SQL server database role?

前端 未结 8 1111
遇见更好的自我
遇见更好的自我 2021-02-01 17:49

I need to make a script to copy one particular database role from one SQL server to another.

Is there an easy way to generate a script that creates the role and all the

8条回答
  •  隐瞒了意图╮
    2021-02-01 18:34

    It's a pain, but everything you're looking for is in a couple of system views: sys.database_permissions, sys.database_principals, and sys.database_role_members. The reason it isn't a treat is because the major_id and minor_id in sys.database_permissions have different meanings based on the class column. But if your permissions are relatively simple, then this might not be so bad. Give it a look and see what you can get.

提交回复
热议问题