Copy SQL Security

Using SQL Server 2000.
I have a new database, which has the exact same structure as an existing database. The data is different, but same Tables, View and Stored Procedures.
Anyway, I'l like to copy the security model from the existing into the new database- same roles, groups etc.
How would I do this?
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

brejkConnect With a Mentor Commented:
Are your databases on the same server?

If so then copying users and roles won't be a problem. Just open Enterprise Manager, go to your database where roles and users are defined, right-click on the database and choose All Tasks... -> Generate SQL Script... Then go to the Options tab in Generate SQL Script window. Check the option "Script database users and database roles" and you are done (click OK). Then just execute the generated script in your second database.

To generate permissions you will have to use another way. Some scripts for that are available here: (but it seems you will have to adopt it for your needs as it just generates permission for single user or single role).

If the databases are on different servers you should also take care about login migration (see the link given by SweatCoder for example).
jdhackettAuthor Commented:
On the same server.
That copy users/roles method you suggested worked perfectly. I'll try the script for the permissions now, and let you know how I get on.
All Courses

From novice to tech pro — start learning today.