SQL Server Error 1702: Fix Column in Table
In this article
SQL Server error 1702 means the CREATE TABLE statement failed because a column definition in your table is invalid—most often a duplicate column name, a missing data type, or a computed column that references itself or another column incorrectly. The fix is to inspect the column list, correct the offending definition, and rerun the statement. You do not need to restart SQL Server or change server settings.
What You'll Need
- Access to SQL Server Management Studio (SSMS) or Azure Data Studio, or another client that can run T-SQL.
- Permission to create tables in the target database (db_owner, db_ddladmin, or CREATE TABLE granted).
- The exact CREATE TABLE statement that failed, so you can compare it line by line with the error message.
Step-by-Step
- Read the full error message. Error 1702 is usually followed by a more specific message naming the column or the reason. In SSMS, check the Messages tab, not just the pop-up. The detail line often says something like “Column names in each table must be unique” or “The column ‘X’ cannot be used in a computed column because it is not valid.”
- Copy the failing statement into a query window. Do not edit it yet. You want to see the exact column list as SQL Server parsed it. If the statement was generated by an ORM or migration tool, find the generated SQL in the tool’s logs or output.
- Check for duplicate column names. Compare every column name in the list. SQL Server treats names as case-insensitive by default, so
CustomerIDandcustomeridare duplicates. Remove or rename the second one. - Check for missing or invalid data types. Every column needs a data type. A common mistake is writing
ColumnName,without a type, or using a type that does not exist in that database compatibility level. For example,datetime2is valid, but a typo likedatetime22is not. - Inspect computed columns. If a column is defined as
AS (expression), make sure the expression references only columns in the same table and does not reference the computed column itself. Also confirm that any function used in the expression is allowed in computed columns—for example, aggregate functions and subqueries are not allowed. - Check for reserved words used as column names. If you use a reserved keyword such as
OrderorGroupas a column name without brackets, SQL Server may misparse the definition. Wrap such names in square brackets:[Order] int. - Verify the table name is not already in use. Error 1702 is about columns, but if a table with the same name exists, you may see a different error (2714). Still, confirm you are not accidentally creating a duplicate table in the same schema.
- Correct the statement and rerun it. Make one change at a time, then execute. If it still fails, the error message will usually point to the next problem. Keep the Messages tab visible.
- Test in a scratch database if unsure. Create a temporary database or use a development copy, run the corrected statement there, and confirm it succeeds before applying it to production.
Common Mistakes
- Ignoring the detail line. Error 1702 alone is generic; the accompanying message is what tells you which column is wrong.
- Assuming the error is about the first column. SQL Server may report the error at the point where parsing fails, which can be later in the list.
- Using a computed column that references another computed column. This is allowed only if the referenced computed column is defined earlier in the same table and does not create a circular reference. Simplify the expression if needed.
- Forgetting that
timestampandrowversionare data types, not column names. Using them as names without brackets can cause confusion. - Copying a CREATE TABLE script from another database that uses a different collation or compatibility level. A column type that works in one database may not be valid in another.
Tips
- Format your CREATE TABLE statement with one column per line. This makes duplicates and missing types obvious.
- Use a consistent naming convention and avoid reserved words entirely.
- If you use an ORM, check its generated SQL before blaming SQL Server. Many 1702 errors come from a model definition that maps two properties to the same column name.
- Keep a known-good CREATE TABLE script for reference; comparing a failing script to a working one often reveals the typo quickly.
- When using computed columns, test the expression in a SELECT statement first to confirm it is valid and returns the expected results.
Troubleshooting
If correcting the obvious duplicate or missing type does not resolve the error, work through these checks:
- Run the statement in a new query window. Sometimes an old batch or a previous error in the same window interferes. Start fresh.
- Check the database compatibility level. Some data types and features are not available at older compatibility levels. You can check with
SELECT compatibility_level FROM sys.databases WHERE name = 'YourDB';. If you are unsure whether a type is supported, test it in a scratch database at the same level. - Look for hidden characters. Copying from a document can introduce non-breaking spaces or smart quotes. Retype the column definition manually or paste into a plain-text editor first.
- Simplify the statement. Create the table with only the primary key column, then add columns one at a time using ALTER TABLE. The step that fails will identify the problem column.
- Check for triggers or defaults that reference missing columns. If you are creating a table with a DEFAULT constraint that calls a function, ensure the function exists and is schema-qualified.
- If the error persists and you cannot identify the cause, capture the exact statement and error text and search Microsoft’s documentation for the specific detail message. Error 1702 is a wrapper; the detail is the key.
Frequently Asked Questions
What does SQL Server error 1702 actually mean?
It means the CREATE TABLE statement failed because one or more column definitions are invalid. The most common causes are duplicate column names, a missing data type, or an invalid computed column expression.
Can error 1702 happen with ALTER TABLE?
Yes. The same column-level problems can cause error 1702 when you add a column with ALTER TABLE, especially if you add a computed column or a duplicate name.
Does error 1702 mean my database is corrupted?
No. It is a syntax or definition error in the statement you submitted, not a storage or corruption issue. Correcting the statement resolves it.
Why does my CREATE TABLE work in one database but fail with 1702 in another?
The databases may have different compatibility levels, collations, or existing schema objects. Check the compatibility level and confirm that any user-defined types or functions referenced in the statement exist in the target database.
How do I find which column is causing error 1702?
Read the full error message in the Messages tab. It usually names the column or describes the problem. If it does not, simplify the statement by creating the table with one column at a time until the error appears.
Can I use reserved words as column names?
Yes, but you must delimit them with square brackets, for example [Order]. Without brackets, SQL Server may misinterpret the statement and raise error 1702 or a syntax error.