See the Microsoft article Transfer logins and passwords between instances of SQL Server for documentation.