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?
Thanks
LVL 1
jdhackettAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

brejkCommented:
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: http://www.sql-server-performance.com/article_print.aspx?id=258&type=art (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).
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.