using SQL Server today, I found a problem with the INSERT into database name. dbo. Table name (field) values (values) When this statement returns an error: SQL Server Principal The database cannot be accessed under the current security context.
So I looked up the information on the Internet and found it because the Trustworthy database property is used to indicate whether the SQL Server instance trusts the database and its contents. By default, this setting is OFF, but you can use the ALTER DATABASE statement to set it to on.
To see which databases have the trustworthy attribute open, the command is as follows:SELECT name, database_id, is_trustworthy_on from sys.databases, the default is msdb open.
To open the database trustworthy property, the command is as follows:
ALTER database name SET trustworthy on
Authorized user access, the command is as follows:
ALTER AUTHORIZATION on database:: Database name to [user name]
SQL Server principal cannot access the database under the current security context