The SQL Server user can only access the specified view. The SQL Server View

Source: Internet
Author: User

The SQL Server user can only access the specified view. The SQL Server View

Use crm
-- Create a role for the current database
Exec sp_addrole 'rapp'
-- Assign view permission grant select on veiw TO [role]

-- Specify the View list
Grant select on v_city TO rapp
Grant select on v_lp TO rapp
Grant select on v_qy TO rapp
 
Go
-- Add a user that only allows access to the specified view: exec sp_addlogin 'username', 'Password', 'default database name'
Exec sp_addlogin 'sa ', 'sa _ pwd', 'crm'

You may not be able to execute the command here. If the password strength is required, create it manually.
Go
-- Add users that can only access the specified view to the rCRM role: exec sp_adduser 'username', 'username', 'Role'
Exec sp_adduser 'sa ', 'sapwd', 'rapp'


How can I create a new user in the sqlserver2005 database so that he has only the select permission on all the databases on the server, or can only operate the view or

1. Assign permissions to the SQL database
Right-click SQL-Server administrative tool login security login Login Name login (New login name)

Enter the corresponding information (here we need to remove the mandatory password policy and force the password to expire. The user must change the password upon next login)

User ing principal select the Database Principal for which we want to set permissions by selecting the database role member identity to set permissions for new users

Generally, you need to check db_owner for all permissions on the entire database (OK)
In this way, we can use the new user name to access our database server, and this user name only has all the permissions of the selected database.

2. sqldatabase assigns permissions to each table

Right-click SQL-Server administrative tool login security login Login Name login (New login name)

Enter the corresponding information (here we need to remove the mandatory password policy and force the password to expire. The user must change the password upon next login)

User ing principal select the Database Principal for which we want to set permissions by selecting the database role member identity to set permissions for new users

Because we need to set each table separately, we will not check db_owner here.

Open the test database login security login user we selected, and you will see the user we just created.

Right-click the created user name, and select "renew ".

Security profile

Add

Determine all objects of a specific type

Object Type Selection table

Confirm tables so that we can see all the tables in the test database.

Then we can set permissions for each table.

I have set the Select permission for both tables. Then, we can use test_name to log on to the test database. We can only perform the Select Operation on the two tables, but cannot perform other operations.

How can I create a user in sql2005 so that this user can only access the table or view I specified or the stored procedure?

You can create a table or try to (tablename) to maintain tables, views, and stored procedures that are allowed to access,

Select 'Grant all on '+ ''+ name +'' + 'username' from tablename
 

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.