Question: when I create a table (T_TableName) using SQL Server Management-Studio, it always creates the table as
Domain\UserName.T_TableName
instead of
dbo.T_TableName
What’s wrong ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you don’t specify a schema explicitly on your table name to be created, it will be created in the user’s current default schema.
I bet the user you’re using has its own personal schema set as its default schema – that’s why your tables get created in his own personal schema.
You can check what database users you have and what their default schema is by inspecting
sys.database_principals(SQL Server 2005 and up):To solve this:
specify the schema you want to use explicitly (best practice anyway!)
change the user’s default schema to
dboBut as a general rule of thumb, I recommend always using the “dbo.” prefix explicitly, if you want to have all your database objects in the dbo schema. Helps with performance, too (ever so slightly) since SQL Server won’t have to go hunting in different schemas, if you explicitly tell it where your db objects live.