Take the 2-minute tour ×
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. It's 100% free, no registration required.

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 stackoverflow.com Jan 22 '12 at 12:56

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

4 Answers 4

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

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

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 ...

or

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 Answer

 
discard

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