SQL Server object owner rename script

cdawes

VIP Member
Does anyone out there have a quick and easy script to run through a SQL
database and change all the object owners to a new value?

Thanks,

Colin




Colin Dawes, Sr. Technical Consultant
Syntax.net
B733.1 to ERP 8.0
Oracle 8i/9i/SQL Server 2K, DB2
 
Find the uid for the table owners:
Select * from sysusers where name = 'table owner '

Update the sysobjects table to change the table owner:
Update sysobjects set uid = ' ' where uid = ' ' and xtype = 'U'
 
You can try a variation of the following script:

sp_msforeachtable "select 'sp_changeobjectowner ?, ''PRODDTA'''"

Then copy the output and execute it.
 
Back
Top