Mssql server2005 specifies a separate user name for the database

Source: Internet
Author: User

-- Create role r_test

The code is as follows: Copy code
EXEC sp_addrole 'r _ test'

-- Grant r_test all permissions on the jobs table

The code is as follows: Copy code
Grant all on jobs TO r_test

-- Grant the role r_test the SELECT permission on the titles table.
Grant select on titles TO r_test

-- Add users that only allow access to the specified table:

The code is as follows: Copy code
Exec sp_addlogin 'username', 'password', 'default database name'

-- Add to database

The code is as follows: Copy code
Exec sp_grantdbaccess 'username'

-- Assign full table permissions

The code is as follows: Copy code
Grant select, INSERT, UPDATE, delete on table1 TO [user name]

The preceding SQL statements can be run directly under the sa user. The following figure shows how convenient the SQL statements are.

 

1.       Log on to SQL Server 2005, "security"-"login name"-"new login name"
(1)     General
Login name (custom)
SQL Server Authentication
Note: Do not use "force password expiration". Otherwise, you cannot create a new user.
(2)     User ing
The user mapped to this login name, select the database you want to log on.
Note: log on to the database using the login name.
You can set the user's access permissions (read, write, and so on ).
SQL Server 2005 supports Setting column access permissions.
(3)     Status
Grant the permission to link to the database engine; enable logon.
2.       After refreshing, when we look at the Database again, a user is added under "security"-"user.
3.       After starting SQL Server 2005, you can use this user to log on to the database.

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.