February 15, 2006 at 10:45 am
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?
February 15, 2006 at 10:47 am
EXEC sp_changeobjectowner 'table', 'dbo'
-Krishnan
February 16, 2006 at 9:37 am
Alternatively - Right click Table, Choose Design - right click for properties
February 16, 2006 at 2:25 pm
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
March 14, 2006 at 12:58 pm
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