I named my tables as Employee
and Department
whereas in MSSMS it is displayed as dbo.Employee
and dbo.Department
respectively and the query works if I use either of them, Why is it so?
-
1`dbo` denotes the [schema name](https://stackoverflow.com/q/11618277/205233). – Filburt Sep 24 '19 at 06:57
-
Url: https://stackoverflow.com/questions/22481820/sql-schemas-dbo-tablename-has-to-go Every table has to belong to a schema in SQL Server; a legacy assumption is that dbo is the default, which it sounds like your migration script assigned all of the tables to. You need to make sure that the account which is connecting to your SQL database has access to the dbo schema. – Mahesh Waghmare Sep 24 '19 at 06:57
-
If you're asking about Microsoft's [tag:sql-server], why is the question tagged [tag:mysql]? They're two completely different products – Damien_The_Unbeliever Sep 24 '19 at 06:59
2 Answers
dbo
schema is the default schema when you create tables, views and etc in SQL Server.
When you create a table it will be placed in default schema and you can call it like dbo.tableName
or just tableName
.
SQL Server ships with ten pre-defined schemas that have the same names as the built-in database users and roles. These exist mainly for backward compatibility. You can drop the schemas that have the same names as the fixed database roles if you do not need them.
You cannot drop the following schemas:
Default schemas :
- dbo
- guest
- sys
- INFORMATION_SCHEMA
For more info see : Microsoft SQL Server schemas
You can create your schemas to allow you to better manage your objects too.

- 732,580
- 175
- 1,330
- 1,459

- 1,119
- 3
- 17
- 28
-
1From the text you're quoting (from somewhere with no attribution): "You **can** drop the schemas that have the same names as the fixed database roles if you do not need them." (My emphasis). Your next sentence: "You cannot drop those schemas". Makes for a very confusing answer – Damien_The_Unbeliever Sep 24 '19 at 07:08
-
I edited that, You cannot drop the following schemas – Mohammad Reza Shahrestani Sep 24 '19 at 07:12
dbo
is a so-called schema. This is similar to a folder.
Every table, view, procedure, etc. is always put into a schema.
But if you don't specify the schema, then dbo
is used.

- 4,127
- 1
- 25
- 54
-
3If you don't specify the schema, your *default schema* is used. Most users are set up with a default schema of dbo, but they need not be. – Damien_The_Unbeliever Sep 24 '19 at 08:55