- Error number
- 207
- 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
- Category
- Syntax & Object Resolution
- Last reviewed
- 23 October 2026
On this page
What it means
Error 207 means the statement is valid T-SQL, but a column name in it does not match any column of the tables, views or derived tables in scope at that point.
After parsing, SQL Server binds every name in the statement to real objects. Error 207 is raised when the table or alias is known but the column name is not, so the quoted text is exactly the column it could not find. The statement is not run; when several columns are wrong you get one 207 per column, which tells you how many need fixing.
Two forms are easy to misread. A value in double quotes, such as "Sara", is a column name in SQL Server (with the default QUOTED_IDENTIFIER ON), so it raises 207 rather than comparing text. And a column that a script adds with ALTER TABLE does not exist yet when the rest of the same batch is compiled. If the problem is the prefix (c.name where c is not an alias), the error is 4104 instead; if the table itself is missing, it is 208.
Common causes
- A typo in the column name, or a name from another environment where the column is spelled differently.
- A column alias from the SELECT list used in WHERE, GROUP BY or HAVING. The alias exists only for ORDER BY and outer queries.
- A string value written in double quotes:
WHERE first_name = "Sara"looks for a column named Sara. - ALTER TABLE ... ADD and a statement that uses the new column in the same batch: the whole batch fails to compile, so the column is never added.
- A column that was renamed or dropped, or a deployment where the code arrived before the schema change.
- A column used without a prefix that exists in none of the joined tables, for example a column of a table you forgot to join.
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.
List every unknown column at once, without running the query
sys.dm_exec_describe_first_result_set binds the statement and returns errors as rows instead of raising them.
SELECT error_number, error_message
FROM sys.dm_exec_describe_first_result_set(
N'SELECT id, emial, phone FROM dbo.Users;', NULL, 0); One 207 row per unknown column (plus a generic 11501 row); the output columns once every name binds.
See the columns the table really has
SELECT c.column_id, c.name AS column_name, TYPE_NAME(c.user_type_id) AS data_type
FROM sys.columns AS c
WHERE c.object_id = OBJECT_ID(N'dbo.Users')
ORDER BY c.column_id; The exact spelling of every column. No rows means the table name or schema is wrong (that is error 208 territory).
Find which table has a column with that name
SELECT OBJECT_SCHEMA_NAME(c.object_id) AS schema_name, OBJECT_NAME(c.object_id) AS table_name, c.name AS column_name
FROM sys.columns AS c
JOIN sys.objects AS o ON o.object_id = c.object_id
WHERE o.is_ms_shipped = 0
AND c.name LIKE N'%mail%'
ORDER BY schema_name, table_name; The tables or views that do have the column, so you know which one to join or which prefix to use.
Check how double quotes are treated in this session
SELECT SESSIONPROPERTY('QUOTED_IDENTIFIER') AS quoted_identifier; 1 (the default for SSMS, sqlcmd and drivers) means text in double quotes is a name, so string values must use single quotes.
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 exact column name
Read-onlyCopy the name from sys.columns or from Object Explorer, and prefix it with the table alias in queries that join tables.
SELECT u.id, u.email
FROM dbo.Users AS u;
Put string values in single quotes
Read-onlySingle quotes delimit strings; double quotes and square brackets delimit names. Use the N prefix for Unicode values.
SELECT id
FROM dbo.Users
WHERE first_name = N'Sara';
Filter on the expression, not on its SELECT alias
Read-onlyRepeat the expression in WHERE, or name it once in a CTE, derived table or CROSS APPLY so later clauses can use it.
WITH named AS (
SELECT id, first_name + N' ' + last_name AS full_name
FROM dbo.Users
)
SELECT id, full_name
FROM named
WHERE full_name LIKE N'A%';
Add the column in its own batch before using it
Changes schemaEnd the batch with GO after ALTER TABLE, so the statements that use the column are compiled after it exists. Inside one batch, put the later statement in EXEC sp_executesql so it is compiled when it runs.
ALTER TABLE dbo.Users ADD phone VARCHAR(20) NULL;
GO
UPDATE dbo.Users SET phone = '000' WHERE phone IS NULL;
GO
Examples
A misspelled column name
CREATE TABLE dbo.Users (
id INT PRIMARY KEY,
email NVARCHAR(255)
);
-- 'emial' is a typo for 'email'
SELECT id, emial FROM dbo.Users;
Msg 207, Level 16, State 1, Line 7 Invalid column name 'emial'.
Reproduced on SQL Server 2025 (17.0.1145.4), 23 October 2026.
A SELECT alias used in WHERE
CREATE TABLE dbo.Users (id INT PRIMARY KEY, first_name NVARCHAR(50), last_name NVARCHAR(50));
GO
SELECT first_name + ' ' + last_name AS full_name
FROM dbo.Users
WHERE full_name LIKE 'A%'; -- the alias does not exist yet in WHERE
Msg 207, Level 16, State 1, Line 4 Invalid column name 'full_name'.
Reproduced on SQL Server 2025 (17.0.1145.4), 23 October 2026.
A string value in double quotes
CREATE TABLE dbo.Users (id INT PRIMARY KEY, first_name NVARCHAR(50));
GO
SELECT id
FROM dbo.Users
WHERE first_name = "Sara"; -- double quotes mean a name, not text
Msg 207, Level 16, State 1, Line 4 Invalid column name 'Sara'.
Reproduced on SQL Server 2025 (17.0.1145.4), 23 October 2026.
How to prevent it
Give every table an alias and prefix every column in multi-table queries, keep string values in single quotes, and use the same column names in every environment. Deploy schema changes before the code that depends on them, and keep each ALTER TABLE in its own batch in migration scripts.
Test a new query with sys.dm_exec_describe_first_result_set or a quick run against a development copy before release. For the clause order that decides where aliases are visible, see the WHERE clause guide.
Common questions
Why can I not use a SELECT alias in WHERE?
Logically, SQL Server evaluates FROM and WHERE before the SELECT list, so the alias does not exist yet. ORDER BY is evaluated after SELECT, which is why ORDER BY full_name works while WHERE full_name raises 207.
Why does my script say the new column is invalid right after I added it?
SQL Server compiles the whole batch before running it. The UPDATE that uses the new column fails to compile, so the batch stops before ALTER TABLE runs. Put GO after the ALTER TABLE.
What is the difference between error 207, 208 and 4104?
207: the column name is unknown. 208: the table or view itself cannot be found. 4104: the prefix in front of a column (an alias or table name) does not match anything in the FROM clause.
Learn more on CodeWithSQL
Official documentation
- MSSQLSERVER_207 (Microsoft Learn)
- SELECT (Transact-SQL): logical processing order
- SET QUOTED_IDENTIFIER (Transact-SQL)
- sys.dm_exec_describe_first_result_set (Transact-SQL)
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.