This script verifies that a specified login name:
- exists (creates it if it does not exist)
- has the correct password (resets it)
- is a member of the sysadmin login role (joins if not a member)
and checks that the database users that should be associated:
- exist (creates them if they do not exist)
- are mapped to the login with specified permissions
Adjust database name(s) in @db_str, adding database names if needed. These database names are the databases you want the script to check/associate with the login.
Adjust the login name and password using @login and @password.
Adjust the default database name using @default_db.
Adjust the owner of the databases using @db_owner (I recommend 'sa' or other sysadmin account so that you can be assured that the login properties can be edited easily later.
Adjust the database role membership using @db_role. You may change this setting and re-run the script for multiple database role memberships.
Adjust the server role membership using @srv_role. This can be used similarly to @db_role.