For example, to generate the commands:
SELECT 'EXEC sp_changeObjectOwner ''' + name + ''', ''dbo'''
FROM sysobjects
WHERE xtype = 'U'
AND USER_NAME(uid) <> 'dbo'
Main Topics
Browse All TopicsI just switched SQL servers and my old stored procedures read dbo.whatever, etc. whereas some of my new tables aren't dbo they're mattbrigh
How do I change those to dbo or do I need to change my stored procedures to mattbrigh from dbo?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Just had this same question earlier today for views--look at the above post and change the 'VIEW' in the query to 'TABLE'
http://www.experts-exchang
Run this, it will change all your tables and procedures to dbo:
--************************
DECLARE @Name varchar(1000)
DECLARE @UID int
-- Declare a cursor and setup
DECLARE NameUpdate CURSOR LOCAL FAST_FORWARD
FOR
SELECT [Name], uid FROM sysobjects
WHERE Type <> 'S'
AND (xType = 'P' OR xType = 'U')
AND uid <> 1
-- Open the cursor
OPEN NameUpdate
-- Fetch the Data into the variables
FETCH NEXT FROM NameUpdate
INTO @Name,@UID
-- Loop through the duplicates setting the next duplicates deletedatetime
WHILE @@FETCH_STATUS = 0
BEGIN
SET @Name = (SELECT name FROM sysusers WHERE uid = @UID) + '.' + @Name
EXEC sp_changeobjectowner @Name, 'dbo'
FETCH NEXT FROM NameUpdate
INTO @Name,@UID
END
CLOSE NameUpdate
DEALLOCATE NameUpdate
--************************
Business Accounts
Answer for Membership
by: ScottPletcherPosted on 2004-09-02 at 14:56:14ID: 11968716
You'd be much better off changing the tables.
Use: EXEC sp_changeObjectOwner -- see Books Online for more details, or post a follow-up comment here :-) .