Creating/capturing user/group scripts

Posted on 2005-05-02
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
    LVL 30

    Accepted Solution

    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.
    LVL 3

    Author Comment

    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

    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
    LVL 3

    Author Comment

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

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Suggested Solutions

    Performance is the key factor for any successful data integration project, knowing the type of transformation that you’re using is the first step on optimizing the SSIS flow performance, by utilizing the correct transformation or the design alternat…
    Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
    Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
    Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

    759 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

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now