Adding a User to a Database

Before a user can use a database, you must set up a username for that user's login ID for that database. The abilities of the user within the database depend on the permissions granted to the username (and to any groups the username is a member of).

It may not be necessary to use the following procedure to add users to the database, because when you add a login ID to SQL Server, you have the option of adding a username for each login ID to each database. (For information, Managing SQL Server Logins.) If you did not add the database user at the time you added the login ID, then use the following procedure to add the user.

You can also use the following procedure to add the guest user to a database, or to add a user for the default login. For information about the guest user and the default login, see Chapter 8, Security Concepts.

    To add a user to a database
  1. Using SQL Enterprise Manager, from the Server Manager window select a server and then open the Databases folder for that server.

    The databases of that server are listed.

  2. Select a database, and then from the Manage menu, choose Users.

    Or open the tree for that database (choose the "" button), click with the right mouse button on the Groups/Users folder, and then from the drop-down menu that appears, choose New User.

    The Manage Users dialog box appears.

  3. In the User Name box, type a username. It can be the same as the login ID.

    If the User Name box is not empty, choose <New User> from the list, and then type the username.

    A username can have as many as 30 characters and must be unique within the database. The characters can be alphanumeric, but the first character must be a letter or the symbols # or _ (for example, CHRIS or USER8). If you don't type a username, the username will be the same as the login ID.

  4. From the list in the Login box, select the login ID for which you will provide a database username.
  5. Optionally, to add the user to a group, select a group from the list in the Group box.

    All users automatically belong to the public group. You have the option of adding the user to one other group.

  6. Choose Add.

    The user is added to the database. The Add button changes to the Modify button.

  7. Optionally, to create an alias for the user, select an alias from the Available Logins list, choose Add, and then choose Modify.

For more information about database users, see Security Concepts.