Read-only permission assignment for SQL Server tables

Source: Internet
Author: User

    1. --Create a test library first test_tmp
    2. --Create two tables based on an existing table
    3. SELECT TOP to test_tab1 from Mistest_09428.dbo.squarer;
    4. SELECT TOP to test_tab2 from Mistest_09428.dbo.squarer;
    5. --Create a role

EXEC sp_addrole ' Test_role1 ';

    1. 11.

12.--Assign the permissions of select to the role test_role1

GRANT SELECT on TEST_TAB1 to Test_role1;

GRANT SELECT on test_tab2 to Test_role1;

    1. 15.

--add login dap570, password dap570, default library is test_tmp

. EXEC sp_addlogin ' dap570 ', ' dap570 ', ' test_tmp ';

    1. 18.

19.--Add the account test to dap570

EXEC sp_grantdbaccess ' dap570 ', ' Test '

    1. 21st.

22.--Assign the role test_role1 to text

. EXEC sp_addrolemember ' test_role1 ', ' test ';

--over.

    1. 25.

26.--Change dap570 to log in to the database test_tmp

    1. 27.

28.--Then test

    1. 29.

30./*

. DELETE from Test_tab1

    1. 32.

. INSERT into Test_tab1 (ingotno) VALUES (' 2222 ')

    1. 34.

UPDATE test_tab1 SET ingotno = ' 3333 '

Read-only permission assignment for SQL Server tables

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.