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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 changing db owner

Author  Topic 

Sarat
Constraint Violating Yak Guru

265 Posts

Posted - 2004-01-30 : 11:00:01
Hi,
I have a database with tables with owner as xyz. I want to change it to dbo. How can I do it all without changing it one by one?
Thanks,
Sarat.

**To be intoxicated is to feel sophisticated, but not be able to say it.**

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-01-30 : 12:31:12
This will write out the commands for you. Just copy the output into another window and execute it. You'll want to verify that it writes out the correct information though.

SELECT 'EXEC sp_changeobjectowner ''' + name + ''', ''dbo'''
FROM sysobjects
WHERE type = 'U' and name <> 'dtproperties'
ORDER BY name

Tara
Go to Top of Page

Sarat
Constraint Violating Yak Guru

265 Posts

Posted - 2004-01-30 : 13:16:25
Thank You very much!

**To be intoxicated is to feel sophisticated, but not be able to say it.**
Go to Top of Page
   

- Advertisement -