This piece of code is worth the price of admission
It happens that I want to move an accounting database from one server to another (we do a lot of Dynamics GP work), and the logins have to be persisted. You can't just recreate them manually because the passwords are encrypted and there are often just too many of them.
To migrate a SQL box:
- Run this script on the old server, it will create a script that will recreate the logins.
- Stop the old server
- Copy the .mdf files to the new server
- Attach the databases on the new server