Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

change owner of table

Status
Not open for further replies.

zhonghandle

Programmer
Jul 17, 2002
12
US
Hi

How can I change the owner of tables from "owner" to "dbo" using a script or stored procedure? If I have 60 tables, it is inpractical to change them manually, so is there a way to change it all together?
Thanks in advance.
 
Yo can use the system stored procedure sp_changeobjectowner. Create a SQL script to generate the SQL statements that change the owners.

Select
'Exec sp_changeobjectowner ''oldowner.[' +
name + ']'',''dbo'''
From sysobjects
Where type='u'
And uid=user_id('Oldowner')

Copy the results from the results window and paste into a new query window. Then Execute the new script. Terry L. Broadbent - DBA
Computing Links:
faq183-874 contains "Suggestions for Getting Quick and Appropriate Answers" to your questions.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top