Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

when I tried to create a table, it is using my ID as the schema name. But when the table is created on my manager's computer, the schema name is "dbo". Why? He might have administrator rights. When I tried to rename by using sp_rename, it is not changing.

share|improve this question

migrated from Jan 22 '12 at 12:56

This question came from our site for professional and enthusiast programmers.

In SSMS go to your database user and click on properties. You will see a field there for default schema.

T-SQL version:

alter user YourDbUser 
with default_schema = YourNewSchema
share|improve this answer

I wish I could combine the answers of three people here, because the answer really is in three parts, and each part has been answered quite well. So I'll mark this as community wiki.

  1. The reason you are getting a different schema other than dbo is because your default schema is not dbo, and you are writing:

    CREATE TABLE foo(...);

    When you do this, SQL Server assumes you want to create the object in your default schema (part of the purpose of having a custom default schema, after all).

  2. To stop this from happening, always specify the schema prefix when creating or referencing objects. When you write the statement this way, there is no way for SQL Server to get it wrong:

  3. To move a table that was accidentally created in the wrong schema, you can use ALTER SCHEMA. For example, if you created and you want it in the dbo schema, you can say:

      SELECT 1 FROM sys.tables AS t
        INNER JOIN sys.schemas AS s
        ON t.[schema_id] = s.[schema_id]
        WHERE = N'foo'
        AND = N'dbo'
      PRINT 'Sorry, couldn't move the object because it already exists.';
share|improve this answer

How are you creating the table? By running a SQL script, or in the SQL Server Management Studio GUI?

When you use a SQL script, you can specify the schema in the script:

CREATE TABLE dbo.MyTable ...


CREATE TABLE someschema.MyTable ...
share|improve this answer

You can find the default schema for a user by looking in the sys.database_principals system view. As to "renaming" it (i.e. moving it to another schema), try:

alter schema [new_schema] transfer [old_schema].[your_object]
share|improve this answer

Your manager is a member of the sysadmin role. You'll have to specify the actual username in the CREATE TABLE statement in order to get the table to not be owned by dbo.

If you want to change ownership after the table has been created, use sp_changeobjectowner.

share|improve this answer
This is not a side effect of the sysadmin role, it's because the manager has the default schema of dbo. And of course, in SQL Server 2005+, the schema name is not the username or the owner - it's just the schema. – Aaron Bertrand Sep 5 '14 at 14:59

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.