January 16, 2019 at 1:20 am
hello everyone,
is there any way to generate a script with all sql server logins . I have plenty of that ,and would be very strange to generate every sql server login from the scratch!
i will appreciate any help?
Kind Regards
January 16, 2019 at 1:50 am
In Object Explorer, navigate to Security -> Logins. Open the Object Explorer Details window. Select all logins, or just those you want to script. Right-click, and choose Script Login as.
John
January 16, 2019 at 1:57 am
John Mitchell-245523 - Wednesday, January 16, 2019 1:50 AMIn Object Explorer, navigate to Security -> Logins. Open the Object Explorer Details window. Select all logins, or just those you want to script. Right-click, and choose Script Login as.John
Thanks a lot John!
January 16, 2019 at 8:43 pm
If you're scripting them out for migration to a new instance or DR purposes (e.g. in-case you need to reinstall SQL Server), you should ensure they're being scripted with the password and SID so that you don't end up with orphaned users in your databases. Scripting directly from SSMS outputs the logins with a random password, and does not include the SID which is required when linking logins to database users that they were previously linked to on another instance of SQL.
Check out sp_help_revlogin for an older, pure T-SQL solution and dbatools Export-DbaLogin cmdlet for a handy PowerShell-based solution.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply