Copy a SQL login without knowing the password

07 Aug 2019 0 minutes to read Contributors

Situation

You dont know the password of a login but you need to copy it to a destination server. 

Solution

You do not need to know the password of a login. You can copy the password (encrypted) to create it on the destination server.

Script

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)

In this article