sql to find user definitions

I am new to sqlserver (came from Oracle). When I copy database in sqlserver from production to test I end up with orphin users. How can I create sql to rebuild users in test from production? I quess I need a script to drop and then receate the users in the database that I just restored from production.

thanks

Charles

[330 byte] By [chart] at [2008-2-26]
# 1
You can use sp_change_users_login to fix the login and user.

Copy from SQL Server Books on Line: the following example shows how to use Auto_Fix to map an existing user to a login of the same name, or to create the SQL Server login Mary that has the password B3r12-3x$098f6 if the login Mary does not exist.

EXEC sp_change_users_login 'Auto_Fix', 'Mary', NULL, 'B3r12-3x$098f6';

Thanks,
Jian

JianZeng at 2007-9-9 > top of Msdn Tech,SQL Server,SQL Server Data Access...

SQL Server

Site Classified