Search code examples
sql-serverdatabasesql-server-2017sql-scripts

Extract complete login settings


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


Solution

  • You can do this using SSMS.

    1. Right-click database name where your user is located.
    2. Tasks->Generate Scripts
    3. In the pop-up window go to "Choose Objects" tab.
    4. Select "Select specific database objects", then select the user you need. Click "Next"
    5. On the next screen click "Advanced" button and set "Script Logins" to true. Click "OK" button
    6. Select preferred script output options and click "Finish" button.

    Note: this will script all logins. Note 2: Images produced using SSMS 2014