You run a simple SELECT, and SQL Server Management Studio answers in red:
Msg 208, Level 16, State 1, Line 3
Invalid object name 'dbo.Employee'.
Msg 208 means SQL Server could not find an object with that name in the place where it looked. The table is not broken and your data is not lost. In almost every case the name is misspelled, you are connected to the wrong database, or the table lives in another schema. This guide shows the quick fix, explains how SQL Server looks up a name, and walks through every common cause with a script to check it.
Part of the SQL Server Errors Explained series. Every script below was run in SQL Server Management Studio on a test instance (SQL Server 2025 Developer) with the demo database of our SQL Server for Beginners course, and the results shown are the real ones. The Payroll schema used for cause 3 was a throw-away table, dropped afterwards.
Contents
- 1. The quick fix
- 2. Why it happens: how SQL Server finds a name
- 3. Cause 2: the wrong database
- 4. Cause 3: the wrong schema
- 5. Find the real name and schema of a table
- 6. Other causes: temp tables, procedures, case, IntelliSense
- 7. How to prevent Msg 208
- 8. Checklist
- Frequently asked questions
1. The quick fix
Read the name inside the quotes of the message, letter by letter, and compare it with the real table name. Here is the query that failed:
USE BiglandDemo;
SELECT FirstName, Salary
FROM dbo.Employee;
Msg 208, Level 16, State 1, Line 3
Invalid object name 'dbo.Employee'.
The table is called Employees, with an s. Fix the name and run it again:
USE BiglandDemo;
SELECT FirstName, Salary
FROM dbo.Employees; -- the real name
| FirstName | Salary |
|---|---|
| Emily | 4200 |
| Michael | 5200 |
| Sarah | 3600 |
| David | 3100 |
| Jessica | 4800 |
| James | 3900 |
Six rows. A missing or extra letter (Employee / Employees, Order / Orders, Departement / Departments) is the most common cause of Msg 208. If the spelling is right, read on: the name is fine, but SQL Server looked in the wrong place.
2. Why it happens: how SQL Server finds a name
When you write a table name, SQL Server resolves it in three steps:
| Step | What SQL Server uses | How you control it |
|---|---|---|
| 1. Database | The database your session is in right now | USE BiglandDemo;, the database dropdown in SSMS, or a three-part name BiglandDemo.dbo.Employees |
| 2. Schema | The schema you wrote; if you wrote none, your default schema and then dbo |
Write schema.table, for example Payroll.Bonuses |
| 3. Name | The exact object name inside that schema | Spelling (and letter case on a case-sensitive database) |
If any of the three does not match, there is no object to read, and you get Msg 208 Invalid object name. The message always shows the name exactly as you wrote it, which is the first clue.
3. Cause 2: the wrong database
Many logins land in master when they connect, and a new query tab in SSMS opens in the login’s default database. The same query, spelled correctly, fails there:
USE master; -- the default database of many logins
SELECT FirstName, Salary
FROM dbo.Employees;
Msg 208, Level 16, State 1, Line 3
Invalid object name 'dbo.Employees'.
The table exists, just not in master. Three ways to fix it:
- Switch database:
USE BiglandDemo;at the top of the script. - Pick the database in the Available Databases dropdown on the SSMS toolbar before you press F5.
- Use a three-part name (database.schema.table), which works from any database:
USE master;
-- three-part name: database.schema.table
SELECT FirstName, Salary
FROM BiglandDemo.dbo.Employees;
Result: the same six rows (Emily 4200 to James 3900), even though the session is still in master.
To stop a login from landing in master, change its default database (needs ALTER ANY LOGIN permission; replace the names with yours):
ALTER LOGIN [YourLogin] WITH DEFAULT_DATABASE = BiglandDemo;
4. Cause 3: the wrong schema
A schema is a folder for objects inside a database. Most tables are in dbo, but teams often group tables in their own schemas (Sales, Payroll, Staging…). In our test, a teammate created a table Bonuses in a schema called Payroll. Right database, right spelling, and still:
USE BiglandDemo;
SELECT EmpName, Bonus
FROM Bonuses;
Msg 208, Level 16, State 1, Line 3
Invalid object name 'Bonuses'.
Without a schema in the name, SQL Server tries your default schema (usually dbo) and then dbo. It never looks in Payroll. Name the schema:
USE BiglandDemo;
SELECT EmpName, Bonus
FROM Payroll.Bonuses; -- schema.table
| EmpName | Bonus |
|---|---|
| Emily | 500 |
| Michael | 300 |
| Sarah | 250 |
5. Find the real name and schema of a table
When you are not sure how a table is spelled or where it lives, ask the catalog view sys.tables in the database you think is right:
USE BiglandDemo;
-- which tables look like the one I want?
SELECT SCHEMA_NAME(schema_id) AS SchemaName,
name AS TableName
FROM sys.tables
WHERE name LIKE '%Employ%'
OR name LIKE '%Bonus%';
| SchemaName | TableName |
|---|---|
| dbo | Employees |
| Payroll | Bonuses |
It also works for views (sys.views) and for any object type (sys.objects). A quick yes/no test is OBJECT_ID, which returns NULL when the name cannot be found from the current database:
SELECT OBJECT_ID(N'dbo.Employee') AS wrong_name,
OBJECT_ID(N'dbo.Employees') AS right_name;
| wrong_name | right_name |
|---|---|
| NULL | 1253579504 |
(The number is an internal object id; it will be different on your server.) If the table is in none of your databases, search them all from SSMS with Object Explorer > the database > Tables, or ask the person who owns the application.
6. Other causes: temp tables, procedures, case, IntelliSense
A #temp table from another session
A local temporary table (one # sign) exists only in the session that created it. Another query tab is another session, so it cannot see it:
-- tab 1
SELECT 1 AS x INTO #Report;
-- tab 2 (another session)
SELECT * FROM #Report;
Msg 208, Level 16, State 1, Line 1
Invalid object name '#Report'.
Run both statements in the same session, or use a real (or global ##) table if several sessions must share the data.
A stored procedure that was created without error
SQL Server lets you create a procedure that uses a table that does not exist yet (deferred name resolution). The error comes only when the procedure runs:
CREATE OR ALTER PROCEDURE dbo.usp_Err208Demo
AS
SELECT Id FROM dbo.NoSuchTable; -- created without any error
EXEC dbo.usp_Err208Demo;
Msg 208, Level 16, State 1, Procedure dbo.usp_Err208Demo, Line 1
Invalid object name 'dbo.NoSuchTable'.
The message names the procedure, so you know which code to open. Typical reasons: the table was renamed or dropped, or the procedure was deployed to a server where the table was never created.
Letter case on a case-sensitive database
Object names follow the collation of the database. Most databases are case-insensitive (our demo database uses French_CI_AS, CI = case-insensitive), so Employees and employees are the same name. On a case-sensitive collation (names containing _CS_ or _BIN), they are two different names and the wrong case gives Msg 208. Check yours with:
SELECT DATABASEPROPERTYEX(DB_NAME(), 'Collation') AS DbCollation;
Red underline, but the query works
If SSMS underlines a table name in red but the query runs fine, that is not Msg 208: IntelliSense simply does not know the new table yet. Press Ctrl+Shift+R (Edit > IntelliSense > Refresh Local Cache).
Works in development, fails in production
The script is right, but the table, view or schema was never created on the other server, or it has another name there. Compare the objects of both databases with the sys.tables query above before you deploy.
7. How to prevent Msg 208
- Always write schema.table:
dbo.Employees,Payroll.Bonuses. It is clearer, it avoids the schema trap, and it lets SQL Server reuse plans better. - Start every script with USE and the right database, and glance at the database dropdown before you press F5.
- Give logins the right default database, not
master. - Let the tools type the names: IntelliSense completion, or drag the table from Object Explorer into the editor.
- Deploy in order: schemas, then tables, then views and procedures, and test the procedures after a deployment.
8. Checklist
| Check | How | Fix |
|---|---|---|
| Spelling | Compare the name in the message with sys.tables |
Correct the name |
| Database | SELECT DB_NAME(); or the SSMS dropdown |
USE YourDatabase; or database.schema.table |
| Schema | SCHEMA_NAME(schema_id) in sys.tables |
Write schema.table |
| Temp table | Same session (query tab)? | Run in one session |
| Procedure | Message shows “Procedure …” | Create or rename the missing table, then fix the procedure |
| Case | Database collation contains _CS_ or _BIN | Use the exact letter case |
Frequently asked questions
What does Msg 208 Level 16 State 1 mean?
208 is the error number (Invalid object name), level 16 is a normal user error that you can correct in your query, and the state is an internal detail. “Line 3” is the line of the batch where the name appears.
The table is in Object Explorer, so why does SQL Server say it is invalid?
Object Explorer shows every database. Your query runs in one database and one default schema. Check the database of your query tab and write the schema with the table.
Can Msg 208 damage my data?
No. The statement stops before it reads or changes anything. In a multi-statement batch, check which statements ran before the error.
What to learn next
Next in SQL Server Errors Explained: Msg 18456, Login failed for user. To learn the basics behind this error, read SELECT, WHERE and ORDER BY and CREATE TABLE, data types and constraints from our free SQL Server for Beginners course.
Sources and further reading
- Microsoft Learn, MSSQLSERVER_208 (Database Engine events and errors), on learn.microsoft.com.
- Microsoft Learn, sys.tables, OBJECT_ID, USE (Transact-SQL) and Deferred name resolution.
More tutorials like this
SQL Server Query Store Tutorial: Find Slow Queries, Compare Plans and Force a Plan
Turn on Query Store, find the most expensive queries with the sys.query_store views and the SSMS reports, compare the plans of one query and…
SQL Server Full Text Search Tutorial: CONTAINS, FORMSOF and CONTAINSTABLE
Search words inside text columns fast: create a full text catalog and index, use CONTAINS, word forms, phrases and rank the best matches with…
SQL Server Partitioning Tutorial: Partition Function, Scheme, SPLIT and SWITCH
Slice a big table into partitions: create a partition function and scheme, load rows, SPLIT a new range and SWITCH old data out in…
