Skip to content
Microsoft SQL Server

SQL Server Error 208

Invalid object name

Applies to: All supported SQL Server versions (2016 to 2025), Azure SQL Database, Azure SQL Managed Instance
Last technically reviewed 23 October 2026 on SQL Server 2025 (17.0.1145.4)
The full message
Msg 208, Level 16, State 1, Line 1
Invalid object name 'dbo.Custmers'.
Other forms of this message
Inside a stored procedure (raised when it runs, not when it is created)
Msg 208, Level 16, State 1, Procedure dbo.usp_ListArchive, Line 3
Invalid object name 'dbo.CustomerArchive'.
Followed by, when the missing table is used by a view
Msg 4413, Level 16, State 1
Could not use view or function 'dbo.vCustomers' because of binding errors.
STRING_SPLIT or OPENJSON in a database below compatibility level 130
Msg 208, Level 16, State 1, Line 1
Invalid object name 'STRING_SPLIT'.
sqlcmd (adds the server name)
Msg 208, Level 16, State 1, Server MYSERVER, Line 1
Invalid object name 'dbo.Custmers'.
Error number
208
Severity
16 (user-correctable error)
State
1
Product
Microsoft SQL Server Database Engine
Versions
All supported SQL Server versions (2016 to 2025), Azure SQL Database, Azure SQL Managed Instance
Last reviewed
23 October 2026

What it means

Error 208 means SQL Server could not find a table, view or other object with the name you used, in the database and schema it searched.

When a statement is compiled, every table and view name is looked up in the current database. A two-part name such as dbo.Custmers is looked up in that schema only; a one-part name such as Invoices is looked up in your default schema, then in dbo. If nothing matches, the statement fails with 208 and the message repeats the name exactly as written, which shows you the database-relative path SQL Server tried.

Procedures and functions are different: SQL Server allows a procedure to be created even when a table it uses does not exist yet (deferred name resolution), so the 208 only appears when the procedure runs, with Procedure ..., Line N pointing at the statement inside it. A missing column in an existing table is error 207, and a missing procedure in an EXEC is error 2812, not 208.

Common causes

  • A typo in the table or view name, or a name that differs between environments.
  • The object is in another schema (Billing.Invoices) and the query uses a one-part name, so it is searched for in your default schema and dbo.
  • The session is connected to a different database than the one holding the table, often master or the login default database.
  • A procedure or view that refers to a table that was never created, was dropped or was renamed: creation succeeds, execution fails.
  • A temporary table used outside the scope that created it: a #table created inside dynamic SQL or a procedure is dropped when that scope ends.
  • STRING_SPLIT or OPENJSON in a database below compatibility level 130, where they are not recognised as functions.

Diagnose it

Read-only These queries only read metadata and dynamic management views. They do not change data, permissions or configuration, so they are safe to run first.

Which database and default schema is this session using?

SELECT DB_NAME() AS current_database, SCHEMA_NAME() AS default_schema, ORIGINAL_LOGIN() AS login_name;
What to look for

If current_database is not the one that holds the table, switch database or use a three-part name. A default schema other than dbo changes where one-part names are looked up.

Find the object in any schema of this database

SELECT SCHEMA_NAME(o.schema_id) AS schema_name, o.name AS object_name, o.type_desc
FROM sys.objects AS o
WHERE o.name LIKE N'%Invoice%'
ORDER BY schema_name, object_name;
What to look for

The real schema and spelling. No rows means the object is not in this database at all.

List procedures and views that refer to objects that do not exist

References that SQL Server could not resolve when the module was created have no referenced_id. Cross-database references also appear here, so check those by hand.

SELECT OBJECT_SCHEMA_NAME(d.referencing_id) AS module_schema, OBJECT_NAME(d.referencing_id) AS module_name,
       d.referenced_database_name, d.referenced_schema_name, d.referenced_entity_name
FROM sys.sql_expression_dependencies AS d
WHERE d.referenced_id IS NULL
ORDER BY module_name;
What to look for

Each module that will raise 208 (or 207) when it runs, with the name it is looking for.

Check the compatibility level for STRING_SPLIT and OPENJSON

SELECT name, compatibility_level
FROM sys.databases
WHERE name = DB_NAME();
What to look for

Below 130, STRING_SPLIT and OPENJSON raise 208 even though the engine supports them.

How to fix it

Each fix is labelled with what it changes. Try read-only checks and the least invasive fix first, and test changes outside production.

Use the correct schema-qualified name

Read-only

Write every object as schema.object. Resolution then no longer depends on the default schema of whoever runs the query.

SELECT id, total
FROM Billing.Invoices;

Query the right database

Client or network side

Set the database in the connection string (Initial Catalog or Database), pick it in the SSMS database list, or use a three-part name for a one-off query in another database on the same instance.

SELECT id, name
FROM SalesDb.dbo.Customers;

Create the missing object before the code that uses it runs

Changes schema

For a procedure that fails with 208, deploy the table it needs (or correct the name in the procedure). Run the diagnostic above after each deployment to catch the rest.

CREATE TABLE dbo.CustomerArchive (
    id   INT PRIMARY KEY,
    name NVARCHAR(100)
);

Create a temporary table in the scope that uses it

Changes schema

A #table created in the outer batch is visible inside dynamic SQL and procedures it calls, but not the other way round. Create it first, then let the inner code fill it.

CREATE TABLE #Staging (id INT);
EXEC sp_executesql N'INSERT INTO #Staging (id) VALUES (1);';
SELECT id FROM #Staging;

Raise the compatibility level for STRING_SPLIT and OPENJSON

Changes configuration

Caution:

The compatibility level changes optimiser behaviour and other rules for the whole database. Test the workload at the new level before changing a production database.

ALTER DATABASE CURRENT SET COMPATIBILITY_LEVEL = 130;

Examples

A misspelled table name

CREATE TABLE dbo.Customers (id INT PRIMARY KEY, name NVARCHAR(100));
GO

SELECT id, name
FROM dbo.Custmers;  -- Customers, not Custmers
Result
Msg 208, Level 16, State 1, Line 2
Invalid object name 'dbo.Custmers'.

Reproduced on SQL Server 2025 (17.0.1145.4), 23 October 2026.

A table in another schema used without its schema

CREATE SCHEMA Billing;
GO
CREATE TABLE Billing.Invoices (id INT PRIMARY KEY, total DECIMAL(10,2));
GO

SELECT id, total
FROM Invoices;  -- looked up in the default schema (dbo), not Billing
Result
Msg 208, Level 16, State 1, Line 2
Invalid object name 'Invoices'.

Reproduced on SQL Server 2025 (17.0.1145.4), 23 October 2026.

A procedure that refers to a missing table (fails only when run)

CREATE PROCEDURE dbo.usp_ListArchive
AS
    SELECT id, name FROM dbo.CustomerArchive;  -- this table does not exist
GO

-- CREATE PROCEDURE succeeded; the error appears on execution
EXEC dbo.usp_ListArchive;
Result
Msg 208, Level 16, State 1, Procedure dbo.usp_ListArchive, Line 3
Invalid object name 'dbo.CustomerArchive'.

Reproduced on SQL Server 2025 (17.0.1145.4), 23 October 2026.

How to prevent it

Always use two-part names (dbo.Customers, Billing.Invoices) and set the database in the connection string rather than relying on the login default database. Deploy tables before the procedures, views and application code that use them.

Because procedures are created without checking their tables, add the unresolved-references query above to your deployment checks, or call every new procedure once in a test environment. The stored procedures and functions lesson covers how procedures are compiled.

Common questions

Why was my stored procedure created if the table does not exist?

SQL Server uses deferred name resolution for tables in procedures, triggers and functions: a missing table is allowed at CREATE time and resolved when the statement first runs. That is when 208 appears, with the procedure name and the line inside it.

Why does the table show in SSMS but my query says invalid object name?

Usually the query window is connected to a different database (check the database list on the toolbar or SELECT DB_NAME()), or the table is in a schema other than dbo and the query uses a one-part name.

Why can I not see my temp table after EXEC?

A #table belongs to the scope that created it. One created inside EXEC or sp_executesql is dropped when that dynamic batch ends, so the outer batch raises 208. Create it in the outer batch first.

Learn more on CodeWithSQL

Official documentation

Last technically reviewed 23 October 2026; examples and diagnostics run on SQL Server 2025 (17.0.1145.4). Message text checked against the engine's sys.messages catalogue.

Still stuck on a SQL Server error?

Browse the full SQL Server error library, or get hands-on help from an experienced SQL professional.