| |

VerySource

 Forgot password?
 Register
Search
View: 1091|Reply: 8

A life-saving question!

[Copy link]

1

Threads

5

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-3-23 09:00:01
| Show all posts |Read mode
The 120 system in our hospital is broken. After using ghost to restore the system, install sql server, restore the backup file the night before, and set the login user permissions. Here comes the problem: configure ODBC, test the login successfully, open the 120 reception desk program prompts the error to open the XX table! Open the query analyzer and write a simple statement: select * from XX prompts "Error 208 object XX does not exist", but open the system tables in the database but everything is normal, using "dbcc checkdb" no error message. If a new table is created in the database, the "owner" is "dbo", and it can be opened with "select * from XX". Please master! Thank you!
Reply

Use magic Report

0

Threads

48

Posts

30.00

Credits

Newbie

Rank: 1

Credits
30.00

 China

Post time: 2020-7-1 23:00:02
| Show all posts
First check who is the owner of the XX table, then take a look
Reply

Use magic Report

0

Threads

48

Posts

30.00

Credits

Newbie

Rank: 1

Credits
30.00

 Switzerland

Post time: 2020-7-2 00:15:01
| Show all posts
select * from username.tablename
Reply

Use magic Report

1

Threads

5

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

 Author| Post time: 2020-7-2 01:15:01
| Show all posts
The table whose owner is ak120 cannot be opened, but the table of dbo can be opened.
Reply

Use magic Report

3

Threads

29

Posts

22.00

Credits

Newbie

Rank: 1

Credits
22.00

 China

Post time: 2020-7-2 09:15:01
| Show all posts
See if the user you log in without a login name, delete and rebuild
Reply

Use magic Report

0

Threads

48

Posts

30.00

Credits

Newbie

Rank: 1

Credits
30.00

 China

Post time: 2020-7-2 10:45:01
| Show all posts
ak120->dbowner
Reply

Use magic Report

0

Threads

6

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-7-6 21:00:01
| Show all posts
Take a look at the logged in user and the owner of the table
Reply

Use magic Report

0

Threads

20

Posts

19.00

Credits

Newbie

Rank: 1

Credits
19.00

 China

Post time: 2020-7-10 16:45:01
| Show all posts
sp_changeobjectowner
Change the owner of the object in the current database.

grammar
sp_changeobjectowner [@objname =]'object', [@newowner =]'owner'

parameter
[@objname =]'object'

The name of an existing table, view, or stored procedure in the current database. The data type of object is nvarchar(517), and there is no default value. object can be qualified by the existing object owner, the format is existing_owner.object.

[@newowner =]'owner'

The name of the security account of the new owner who will soon become the target. The data type of owner is sysname, and there is no default value. The owner must be a valid Microsoft® SQL Server™ user or role or Microsoft Windows NT® user or group in the current database. When specifying a Windows NT user or group, specify the name of the Windows NT user or group known in the database (added with sp_grantdbaccess).

Return code value
0 (success) or 1 (failure)

Annotate
The object owner (or a member of the group or role that owns the object) has special permissions on the object. The object owner can execute any Transact-SQL statements related to the object (such as INSERT, UPDATE, DELETE, SELECT, or EXECUTE), and can also manage the permissions of the object.

If the security account that owns the object must be removed, but at the same time you want to keep the object, use sp_changeobjectowner to change the object owner. This process removes all existing permissions from the object. After running sp_changeobjectowner, you need to reapply any permissions you want to retain.

For this reason, it is recommended to write scripts for existing permissions before running sp_changeobjectowner. Once the ownership of the object is changed, the script may be used to reapply permissions. Before running the script, you need to modify the object owner in the permissions script. For more information about writing database scripts, see Writing database documentation and scripts.

You can use sp_changedbowner to change the owner of the database.

Authority
Only members of the sysadmin fixed server role and db_owner fixed database role, or both the db_ddladmin fixed database role and the db_securityadmin fixed database role, can execute sp_changeobjectowner.

Examples
The following example changes the owner of the authors table to Corporate\GeorgeW.

EXEC sp_changeobjectowner'authors','Corporate\GeorgeW'
Reply

Use magic Report

1

Threads

5

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

 Author| Post time: 2020-7-15 21:15:01
| Show all posts
Thank you for your support, as everyone said, change the owner to dbo, the problem is solved smoothly!
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list