Sql-server – Scipt User roles and permissions

access-controlpermissionssql serversql-server-2012users

I am having issues with the user accounts in SQL Server v 11.0.6020. I need to run a script that will allow for the copy of the principal user account: 'TrainID1' and all of the user rights and permissions so that when I get the other users logged in, they can access the DB's and run the applications that connect to the SQL DB's.
So I have the user: 'TrainID1', and that user connects to the SQL DB: 'TrainID_01' DB, so I need to have TrainID2 to 42 user accounts allowed in SQL Security for all of the other Data Bases like: TrainID_02, TrainID_03 and so on…

Best Answer

I recommend you have a look at the procedure sp_dbpermissions by Kenneth Fisher.

I have been using it and it allows you to list all the permissions of a particular user in a database, and gives you all the scripts to copy all those permissions and apply them on a different database.

In case you want to apply them on a different server as well, that is fine too, but don't forget to create the server login first.