Changing Object Owner

  • Please help, I have 200 tables with a XXX owner and I need to change it to DBO.  I found this command

    sp_changeobjectowner but is one table at the time, I know there is a way to change them.

    Please HELP,

     

    Your help is greatly appreciated!!! 

  • You could hack the sytem tables but I'd advise against it.  The following will generate the stored proc calls to change everything not owner by DBO to DBO, no strenuous typing required.

    select 'sp_changeobjectowner "' + u.name + '.' + o.name + '","dbo"' from sysobjects o, sysusers u

     where type = 'u'

     and u.uid = o.uid and u.uid <> 1


    And then again, I might be wrong ...
    David Webb

  • Cool deal!

    That worked perfect.

    Thanks a lot... You rock!

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply