Generally it is something that occurs when a backup to another machine is
created... and again, generally that backup is there for the developers and
testers to use unless there has been a disaster and you are restoring a
system from scratch. For me, restoring just for developers and testers
means a limited set of users and I have a job that runs on the agent that can
create all the non-windows authenticated users who will be working on the
test database. You can script all the users from the database and from the
server (msdb) but in general, the only ones that come across are the ones
that are Windows Authenticated. The SQL Authenticated users must be
reactivated as you have already noted.
If you give rights to a sql authenticated user, then you will use the EXEC
sp_change_users_login 'Update_One', 'Mary', 'Mary' command you listed but
only if Mary's login is already created on the server. And you need to do it
for each sql authenticated user on that database.
If the database is copied to a new server, you will also need to recreate
those logins with their specific passwords on that server as well.
To get back to your question, when you restore from backup or when you
detach and reattach the copy, you may be doing it with a script on the SQL
Agent. If so, add the [EXEC sp_change_users_login 'Update_One', 'Mary',
'Mary'] scripts to the end of the job that performs the restore or reattach
routine to save yourself the trouble of recreating them.
To script the users, right click the database (and if memory serves me on
SQL 2000) to get a window for creating scripts. If you select all (a check
box in the upper right I think) you will have the option to script procedures
and the like which you won't need. On the second tab, you have the ability
to script the users. That's what you are looking for.
If not, you will probably get flak from Mary and if she is your boss, you
won't forget the next time around.

Signature
Regards,
Jamie
> Hi,
> I am able to activate sql users by exec EXEC sp_change_users_login
> 'Update_One', 'Mary', 'Mary'
>
> How do I run a scrypt to activate windows user?
Mecn - 10 Jul 2008 22:56 GMT
Got it Thanks a lot, I appreciaterd.
> Generally it is something that occurs when a backup to another machine is
> created... and again, generally that backup is there for the developers
[quoted text clipped - 43 lines]
>>
>> How do I run a scrypt to activate windows user?