SQL Server Procedure to Change Object Owner

by Niklas Richardson 12:35 pm Wednesday, 25 July 2007.

Have you ever needed to change the owner of a table (or for any object) in SQL Server?

We just had the need to do that today and found this nifty script from Microsoft to do it. Basically it creates a stored procedure that when run creates a list of commands that you can then run against the database to change all the owners for all the relevant objects.

So by using Query Analyzer do the following steps:

(1) Run the create stored procedure script against the database in Query Analyzer
(2) Then run the command “exec chObjOwner ‘test’,'dbo’” against the same database to create the commands
(3) Then copy and paste the outputted commands into the execute window, and run them all!
(4) All objects will have been updated!

Hope this helps someone!

No Comments »

  1. Great minds think a like - similer post on the same day: http://www.succor.co.uk/index.cfm/2007/7/25/Change-MSSQL-table-owner

    Comment by Nick Tong — Friday, 3 August 2007 @ 10:09 pm

RSS feed for comments on this post. TrackBack URL

Leave a comment