Thank this author by sharing:
By Lester Policarpio,
This script will produce the server login/role and db user/role in all databases in the server.It is best advised that you first delete/recreate orphaned users for best results. Copy the result of the query and paste to the destination server to recreate logins.
As a member of SQLServerCentral, you get free access to loads of fresh content: thousands
of articles and SQL scripts, a library of free eBooks, a weekly database news roundup,
a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals
that makes it such a success.