How to resolve a problem with owner (owner) when referencing an object

Source: Internet
Author: User
Tags sql query
Object | solve | problem description :From Elsewhere Copyto a database DB, when attached, the owner of the object is not Admini, must be written every time the query is SELECT * from admini.***In order to find out. Is there any way to do without the front AdminiDo you want to (without modifying the owner's premise)? Note: Already in the security -Landing "There is also a new AdminiUser, the default database is set to DB, the permissions are sufficient, but they are used under Query Analyzer AdminiLogin, query or write Adminiprefix, otherwise prompt object name is invalid Problem Solving method: If it's a SQL, log in with a user , If you do not specify the owner , When you visit an object , The default owner is the current logged-on user if it is theWords , In the security of the data --User --Right click on your users admin--Property , See what the default architecture is , This default schema determines when you access the object , If you do not specify the owner , Use that Owner (SQLIn , ownerinto a frame. ) will result in an exception that does not match the above argument: If you are in a database DBIn Adminiis an orphaned user, the situation is not the same as described above (attaching or recovering a database is prone to orphaned users), that is, the owner must be specified when referencing an object. Orphaned users behave as follows: You can create only AdminiLogin , and paired with the server role DBThe permissions, or the DBTo create a name in the AdminiThe user is associated with the login. To query DBIn the case of orphaned users, execute the following statement: Use Dbgo EXEC sp_change_users_login ' " Ways To resolve orphaned users: Resolving this anomaly as long as the isolated user is resolved, in determining the Adminiis an orphaned user, you can execute the following statement: Use Dbgo--fix orphaned user exec sp_change_users_login ' auto_fix ', ' Admin ', NULL, ' password '; --This password refers to the password that is assigned to the login when SQL automatically creates a login, if the login is not established in advance admin, exec sp_addrolemember ' db_owner ', ' Admin '

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.