Change Table Owner

  • Does anyone know how to change the owner of a table? I want to change the owner from Dimitri to dbo. How do I do this?

  • EXEC sp_changeobjectowner 'table', 'dbo'

    -Krishnan

  • Alternatively - Right click Table, Choose Design - right click for properties

  • And if you have a whole lot that need changing, run this in Query Analyzer, outputting to text (not grid), then paste the results into another window to run them all at once

    -- Generate script to chagne ownership

    select 'sp_changeobjectowner ' + ''''+'DIMITRI.'+name+'''' + ', ' + '''dbo''

    GO'

      FROM sysobjects

      WHERE xtype in ('U', 'V', 'P')  -- V = View,  U = tables, P = Stored Procs

            and uid = nn    -- enter DIMITRI's uid from sysusers

      order by xtype, name

  • Thank you very much. I was looking forward to write the cursor because I wanted to change the ownership for quite a few tables.

Viewing 5 posts - 1 through 4 (of 4 total)

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