SQL Server: Change the Owner of All Tables to "dbo"

Reference for me. Reference for you.

sp_MSforeachtable @command1="EXEC sp_changeobjectowner '?','dbo'"

Chrissy is a PowerShell MVP who has worked in IT for nearly 20 years, and currently serves as a Sr. Database Engineer in Belgium. Always an avid scripter, she attended the Monad session at Microsoft’s Professional Developers Conference in Los Angeles back in 2005 and has worked and played with PowerShell ever since. Chrissy is currently pursuing an MS in Systems Engineering at Regis University and helps maintain RealCajunRecipes.com in her spare time. She holds a number of certifications, including those relating to SQL Server, SuSE Linux, SharePoint and network security. She recently became co-lead of the SQL PASS PowerShell Virtual Chapter. You can follow her on Twitter at @cl.

Posted in SQL Server
5 comments on “SQL Server: Change the Owner of All Tables to "dbo"
  1. WebDevBB says:

    Hi Chrissy… Thanks very much for this. I wish I had seen your post before. I had a need for this script a couple days ago but at least I have it now. :)

  2. Robert says:

    Thank You

    Very Useful

  3. ben says:

    you rock. curls, ninjas, and SPROCS. its what dreams are made of!
    thank you!

  4. Alex says:

    Hi Chrissy, i’m having a problem to delete or rename a database, i want to delete it manually, but it says i don’t have permission, can you help me please :(.

    Thank you.

  5. Steve says:

    This is one of the most useful pieces of SQL script I have ever come across! Thank you so much!

Leave a Reply

Your email address will not be published. Required fields are marked *

*