Change the owner of tables and store procedures in SQL Server

Root Folder > SQL Server
By default who over creates the table, store procedure or the View is the owner of the object. There are several scripts you can run to change the db back to dbo . There is one good thread you can refer to : In additional note there is a script you can run in query analyzer and it creates the query ( first go to menu / query / set : result in text ) and then copy and paste the result back to query analyzer and it simply changes all owners.

SELECT 'EXEC(''sp_changeobjectowner @objname = '''''+ ltrim(u.name) + '.' + ltrim(s.name) + '''''' + ', @newowner = dbo'')'
FROM sysobjects s, sysusers u
WHERE s.uid = u.uid AND u.name <> 'dbo' AND xtype in ('V', 'P', 'U')AND u.name not like 'INFORMATION%'
order by s.name

http://weblogs.asp.net/owscott/archive/2004/01/30/65229.aspx

Add Feedback