I restored a database from one server to another. After restoring the database, I came across this issue of orphaned users which I resolved using -
exec sp_change_users_login 'Update_One', 'UserName', 'LoginName'
Now, this particular user is linked with given server login. All good until here.
However, I am still having an issue that is to do with 'Securables'
As permission to many database objects was missing for this user, I Googled and found out a way - Generate Script by -
1. Select Database
2. Right click database to see context menu
3. Select 'Tasks',
4. From the sub-menu, select 'Generate Scripts'
5. Select 'Set Scripting Options'
6. From 'Advanced' section - set 'Object Level Permissions' to true.
So, we will get a list of all the GRANT SELECT/GRANT EXECUTE scripts etc.
But, I am looking for another way, where I don't have to run through this wizard every time and I can write my own database script to list database securables and permissions for a given database user.
Can anyone please guide which (system)database tables should I look for?
Thank you!