Go Back To List
SQL Server
SQL Server 2005 (Change Table Owner name (Scheme Name) to dbo)
Next Article
SQL Server 2005 (Import All Table information with SQL Scripting)
Coding Article #: 7 - Published On: February 24, 2010 @ 08:45:23 AM - Last Updated on: July 13, 2012
This article has been Favorited 1 times
Join today, and add this to your favorites.
Coding Source - Share on MySpace Coding Source - Share With Facebook Coding Source - Share on Twitter Coding Source - Share on Reddit Coding Source - Share on Digg It Coding Source - Share on Stumble Upon It Coding Source - Share on Delicious
Share With Friends (Updated 6-8-2010)

Supported Files
No Files for this Article.
Screenshot of Source Code
Coding Source - SQL Server 2005 (Change Table Owner name (Scheme Name) to dbo)
SQL Server (This method applies to SQL Server 2005, though may work in other versions as well, is only tested in the SQL Server 2005 Environment)
Need to change the Scheme Name of your tables?

(Your account must be part of the {sysadmin} in order to perform this action)

Create a new Query on the Database in Question that you want to alter the name of the table owner (Scheme Name) from your username to the default dbo.

Copy and paste the code below into a new query. Change the SCHEME_USERNAME
To match your situation.

----------
The output will look something like this.


ALTER SCHEMA dbo TRANSFER SCHEME_USERNAME.Members
ALTER SCHEMA dbo TRANSFER SCHEME_USERNAME.MySubCats
ALTER SCHEMA dbo TRANSFER SCHEME_USERNAME.siteinformation


Copy "Your Output" into a New Query Window, and execute it.
This will change your Table Owner "Scheme" to the DBO owner.

SELECT 'ALTER SCHEMA dbo TRANSFER ' + s.Name + '.' + p.Name FROM sys.Tables p INNER JOIN
sys.Schemas s on p.schema_id = s.schema_id WHERE s.Name = 'SCHEME_USERNAME'

Post to Facebook about: SQL Server 2005 (Change Table Owner name (Scheme Name) to dbo)