The server subject cannot access the database in the current security context

Source: Internet
Author: User
When I used sqlserver today, I found a problem, that is, using the insertinto database name. dbo. when a statement such as table name (field) values (value) returns an error: the sqlserver server subject cannot access the database in the current security context. So I found some information on the Internet and found that the trustworthy database attribute is used to specify

When I used sqlserver today, I found a problem, that is, using the insert into database name. dbo. when a statement such as table name (field) values (value) returns an error: the sqlserver server subject cannot access the database in the current security context. So I found some information on the Internet and found that the trustworthy database attribute is used to specify

When SQL Server is used today, an error is returned when the insert into database name. dbo. Table Name (field) values (value) statement is used:

The server subject cannot access the database in the current security context.

So I found some information on the Internet and found that the trustworthy database attribute is used to indicate whether the SQL Server instance trusts the database and its content. By default, this setting is OFF, but you can use the alter database statement to set it to ON.

To view which databases have the trustworthy attribute enabled, run the following command:

SELECT name, database_id, is_trustworthy_on FROM sys. databases, Which is enabled by msdb by default.

To open the database trustworthy attribute, run the following command:

Alter database name SET TRUSTWORTHY ON

To authorize a user access, run the following command:

Alter authorization on database: DATABASE name TO [user name]

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.