28 Sep 2019 0 minutes to read Contributors
You dont know the password of a login but you need to copy it to a destination server.
You do not need to know the password of a login. You can copy the password (encrypted) to create it on the destination server.
We create the script on the source server. We include checks to see if the login already exists when we create it on the destination server. We will take the encrypted password (convert it to NVARCHAR(MAX) and the SID to make sure they are the same on source and destination server (in case you want to copy the databases also, the security stays the same)
123456 SELECT 'IF(SUSER_ID('+QUOTENAME(SL.name,'''')+') IS NULL)BEGINCREATE LOGIN '+QUOTENAME(SL.name)+' WITH PASSWORD = '+CONVERT(NVARCHAR(MAX),SL.password_hash,1)+' HASHED, SID = '+CONVERT(NVARCHAR(MAX),SL.sid,1)+'END'FROM sys.sql_logins AS SLWHERE name not like '##%##' and name <> 'sa'
In this article
Please choose a monitoring environment to connect to:
Download link successfully sent. Check your email for details.
An email with a link for creating your password is sent to