How SQL Server creates users and roles

Source: Internet
Author: User
Tags table name

--First Use sp_addlogin to add login exec sp_addlogin ' username ', ' password ', default database

--then grant the user access to a database named exec sp_grantdbaccess ' username '

--finally give the user specific permissions, such as the ability to select a table, depending on the permissions that the user needs to set the use database name grant Select on table name to user name such as to create a new account Appuser, password is pass, and allows the user to have select and update permissions on the test table for the APPDB database, then execute

exec sp_addlogin ' appuser ', ' Pass ', ' appdb ' to use appdb exec sp_grantdbaccess ' appuser ' Go use appdb grant Select,update on Test to Appuser go Grant name grant-give a user, a group or all user access rights syntax GRANT privilege [, ...] On object [, ...] to {public | Group Group | Username} Enter privilege the possible permissions are: All columns/fields of the table/view for the SELECT access declaration. Inserts all column fields into the declared table.

All columns/fields for the table of the update declaration.

Delete Deletes all rows from the declared table.

Rule defines the rules on a table/view (see the CREATE ruleset statement).

All permissions are granted.

object to which the permission is given.

The possible objects are: The table View sequence public representative is shorthand for all users.

Group group to which you want to assign permissions.

Username the name of the user who will be given permission.

Public is shorthand for all users.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.