I am using SQL Server 2017. I have created a login with mapping and various roles.
How can I get the create script of the complete login?
The script must contain all mapping and role information.
Thanks for any help
You can do this using SSMS.
- Right-click database name where your user is located.
- Tasks->Generate Scripts
- In the pop-up window go to "Choose Objects" tab.

- Select "Select specific database objects", then select the user you need. Click "Next"
- On the next screen click "Advanced" button and set "Script Logins" to true. Click "OK" button

- Select preferred script output options and click "Finish" button.
Note: this will script all logins.
Note 2: Images produced using SSMS 2014