When we reload the system, or reload the database, after attaching the database, we find that there is a username in the database, but there are no login names in SQL Server.
For example
First look at the username is the user name of his last system
Now let's go ahead and add this login name
Click Cancel
Go to Query Analyzer and select the database you want to repair
Sp_change_users_login ' This can query orphaned users under the current database
We only need to select the current database for you to fix the database and then run sp_change_users_login ' update_one ', ' username ', ' login '
The system prompts you to fix an orphaned user.
Users who refresh the database will see that the user name and login name correspond.
In addition to a little tip, sometimes LDF files will be very large this time, now you want to compress the database Query Analyzer inside
Inside the operation of the DUMP transaction databasename with NO_LOG, and then shrink the log file, the final result is 1024K
In addition: Modify the sqlserver2000 database port