server| objects
General development, SQL Server's database owner is dbo. But for security, it's sometimes possible to replace it with a different name.
The owner transform is not very convenient. Here are two kinds of references
One:
---****************** Change permissions to add HHRC users *************************
--STEP1 Add third party users, such as "CHN"
--STEP2 run SQL, add object permissions to third party users
--STEP3 Add HHRC User
--STEP4 run SQL, move object permissions to 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
The second kind.
--Manually Modify system tables
--The device can modify the table manually
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