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
IN SSMS right clicking user/login/role node and selecting 'Script As' will script this particular user / login / role. You can't script role mebership this way though.
Visual Studio with 'Database Drvelopment' option and Red Gate SQL Compare can generate the change script between to databases, this includes users, roles and role membership.
Generated by VS role membership looks like this:
EXECUTE sp_addrolemember @rolename = N'db_datareader', @membername = N'DOMAIN\User';
If you don't have VS, you can either write those manually, or create a sql script for generating them.
I'm sure there also should be a free tool to do something like this, but since I don't need it as I have Visual Studio, I never looked for it.
Edit: I just realized that I'm answering a wrong question, you are asking about role permission and I'm telling you about role membership. Sorry about this. I'll leave this answer here in case it can be useful to someone else. Answer by Alex Aza looks good.