In general development, the database owner of SQL Server is DBO. But for security, it may be changed to another name.
It is not very convenient to change the owner. Two types are listed here for reference.
I:
-- -***************** Change permissions to add hhrc users *************** **********
-- Step 1 add a third-party user, such as "CHN"
-- Step 2 run the SQL statement and add the object permission to a third-party user
-- Step 3 add an hhrc user
-- Step 4 run the SQL statement and move the object permission to the hhrc user
Declare @ Tblname Varchar ( 30 )
Declare @ Tblown Varchar ( 50 )
Declare Tbl_cur Cursor For
Select Name From Sysobjects Where UID = ' 5 ' And Status > = 0 And Xtype In ( ' U ' , ' P ' )
-- Select * From sysusers
Open Tbl_cur
Fetch Next From Tbl_cur Into @ Tblname
While @ Fetch_status = 0
Begin
Set @ Tblown = ' Web56433. ' + @ Tblname
Exec Sp_changeobjectowner @ Tblown , ' CHN '
Print @ Tblname
Fetch Next From Tbl_cur Into @ Tblname
End
Close Tbl_cur
Deallocate Tbl_cur
Second. -- Manually modify system table
-- The device can manually modify the table
Exec Sp_configure ' Allow updates ' , 1
Reconfigure With Override
-- Change object owner
Update Sysobjects Set UID = 1 Where UID = 5
Update Sysobjects Set UID = 5 Where UID = 1 And Xtype ! = ' S '
Update Sysobjects Set UID = 1 Where Name = ' Syssegments '
Update Sysobjects Set UID = 1 Where Name = ' Sysconstraints '
Exec Sp_configure ' Allow updates ' , 0
Reconfigure With Override