On this page
Why it happens
Error 208 means SQL Server tried to bind your statement to an object and could not find one that matches the name you wrote. The name in quotes, for example dbo.Custmers, is exactly what the parser looked for and failed to locate. Because the object cannot be resolved, the whole statement is stopped at compile time with severity 16, a normal user-correctable error.
The most common cause is simply a typo in the object name. Just as common is being connected to the wrong database, so the object exists but not where you are looking, or the object living in a schema other than dbo while you referenced it with no schema or the wrong one. When you write an unqualified name, SQL Server looks in your default schema, which may not be where the object lives.
The object may also have been dropped or renamed since the query was written, or you may be querying a temporary table that no longer exists or is out of scope for the current session. In every case SQL Server has nothing to bind the name to, so it reports the name back to you as invalid.
Examples
A misspelled table name
-- The table is dbo.Customers, but the query misspells it.
SELECT id, name
FROM dbo.Custmers;
Msg 208, Level 16, State 1, Line 3 Invalid object name 'dbo.Custmers'.
An object in a non-dbo schema referenced without its schema
-- The table really is Sales.Orders, but it is referenced
-- with no schema, so SQL Server looks in the default schema.
SELECT order_id, total
FROM Orders;
Msg 208, Level 16, State 1, Line 4 Invalid object name 'Orders'.
A temp table that is out of scope
-- The temp table was created in another session or already
-- dropped, so it cannot be resolved here.
SELECT * FROM #StagingRows;
Msg 208, Level 16, State 1, Line 3 Invalid object name '#StagingRows'.
How to fix it
Check the spelling and confirm the object exists
Verify the exact name in the system catalog. If the query returns no rows, the object is not in the current database under that name and you have a typo or the wrong database.
SELECT s.name AS schema_name, o.name AS object_name, o.type_desc
FROM sys.objects AS o
JOIN sys.schemas AS s ON s.schema_id = o.schema_id
WHERE o.name = 'Customers';
Switch to the correct database or fully qualify the name
If the object lives in another database, either change context with USE or reference it with a three-part database.schema.object name so SQL Server looks in the right place.
-- Option A: change the current database
USE MyDb;
SELECT id, name FROM dbo.Customers;
-- Option B: fully qualify the name
SELECT id, name FROM MyDb.dbo.Customers;
Always use a two-part name with the schema
Reference objects by schema.object so resolution does not depend on your default schema. Use Sales.Orders, not just Orders.
SELECT order_id, total
FROM Sales.Orders;
Recreate the object or fix the reference if it was dropped
If the object was dropped or renamed, either point the query at the new name or recreate the object. Guard the check so the create runs only when the object is missing.
IF OBJECT_ID('dbo.Customers', 'U') IS NULL
CREATE TABLE dbo.Customers (
id INT PRIMARY KEY,
name NVARCHAR(100)
);
For temp tables, confirm the session and scope
A local temp table (#name) is visible only in the session that created it and disappears when that scope ends. Create and use it in the same session, or use a global temp table (##name) if it must be shared.
IF OBJECT_ID('tempdb..#StagingRows') IS NULL
CREATE TABLE #StagingRows (id INT, name NVARCHAR(100));
SELECT * FROM #StagingRows;
How to prevent it
Always reference objects with a two-part schema.object name so name resolution never depends on the caller default schema. This alone prevents most 208 errors caused by objects that live outside dbo.
Deploy objects before the code that uses them, keep schemas consistent across environments, and confirm you are connected to the intended database before running a query. For the rules behind identifiers and qualification, see the SQL syntax guide and the SQL tutorial.
Common questions
What is the difference between error 207 and error 208?
Error 208 (invalid object name) means SQL Server cannot find the table, view, or object you named at all. Error 207 (invalid column name) means the object was found, but a column you referenced does not exist on it. In short, 208 is about the object and 207 is about a column inside a valid object. See our page on error 207 for the column case.
Why does USE database matter for error 208?
An unqualified or two-part object name is resolved inside whatever database is your current context. If you are connected to the wrong database, the object simply is not there and SQL Server reports it as invalid. Running USE MyDb (or using a three-part database.schema.object name) points the query at the database that actually contains the object.
How do I fix SQL Server error 208?
Check the object name for typos, confirm you are in the correct database, and qualify the name with its schema (for example Sales.Orders). Query sys.objects to verify the object exists, switch databases with USE if needed, and recreate the object if it was dropped. For temp tables, make sure they are still in scope for your session.