Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
mr_mist
Grunnio
1870 Posts |
Posted - 2003-11-10 : 03:53:53
|
| HiI've recently had a database restored that has lots of objects (view, stored procedures, tables) all owned by a user that does not exist on the server. I'd like to change the owner of all the objects in the database to sa/dbo. Is there a quick method for changing the owner of all the objects in a db? Anyone have a nifty piece of code to do it?-------Moo. :) |
|
|
rksingh024
Yak Posting Veteran
56 Posts |
Posted - 2003-11-10 : 04:02:40
|
| This will help you...SELECT 'EXEC(''sp_changeobjectowner @objname = '''''+ ltrim(u.name) + '.' + ltrim(s.name) + '''''' + ', @newowner = dbo'')'FROM sysobjects s, sysusers uWHERE s.uid = u.uid AND u.name <> 'dbo' AND xtype IN ('V', 'P', 'U')AND u.name not like 'INFORMATION%'order by s.nameRamesh Singh |
 |
|
|
mr_mist
Grunnio
1870 Posts |
Posted - 2003-11-10 : 04:54:24
|
| Thanks I will give it a try.-------Moo. :) |
 |
|
|
|
|
|