Creating/capturing user/group scripts

I am rather new to SQL Server 2000 and I have always created my users using the enterprise manager.

How can I export the users and groups into a script so I can recreate them if I need to rebuild the databases with scripts only?

If I can't export the existing users/groups, at least show me the syntax for creating a group, a user and then how to attach the user to the group.

Who is Participating?
nmcdermaidConnect With a Mentor Commented:
Right click on your database

All Tasks/Generate SQL Script

On the options tab you will find various options for scripting users and logins

You can use this to script out your users.

The script it creates looks pretty complicated but it should give you the idea.
schworakAuthor Commented:
That was exactly what I needed!

I just selected the user / roll and loggin and object permissions boxes, generated the scripts and I was done.

I just wanted to make sure I didn't have to recreate the logins by hand if something ever went wrong. I have the database scripts but I created them by hand in the first place.

Thanks for helping me down the road to learning this DBA stuff.
No worries.

I dont think the EM scripts have passwords in them (to be expected) so you might have to substitute them in if you ever need to run them
schworakAuthor Commented:
Yeah, no passwords. But I am using windows login validation so just getting the users built works great.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.