Creating/capturing user/group scripts

Posted on 2005-05-02
Medium Priority
Last Modified: 2010-03-19
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.

Question by:schworak
  • 2
  • 2
LVL 30

Accepted Solution

nmcdermaid earned 1000 total points
ID: 13914343
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.

Author Comment

ID: 13917207
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.
LVL 30

Expert Comment

ID: 13922247
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

Author Comment

ID: 13922754
Yeah, no passwords. But I am using windows login validation so just getting the users built works great.

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Suggested Courses

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question