SQL Server error 1009, "The keyword 'DEFAULT' is not allowed in this context," means you used the DEFAULT keyword somewhere the parser does not accept it — most often inside a DEFAULT constraint definition, a VALUES list, or a stored procedure parameter list. The fix is to remove DEFAULT from that spot and use the correct construct instead: a literal value in the constraint, the DEFAULT keyword only in an INSERT statement, or a default parameter value without the word DEFAULT in a CREATE PROCEDURE header.

What You'll Need

  • SQL Server Management Studio (SSMS) or Azure Data Studio connected to your database, or another client that can run T-SQL.
  • Permission to alter the table or procedure involved (ALTER permission on the object, or db_owner).
  • The exact statement that produced the error, so you can see which clause contains DEFAULT.

Step-by-Step

  1. Read the error message and locate the line. SSMS shows the message with a line number in the Messages tab. Click the message; the cursor jumps to the offending line. If you are running a script with many statements, the line number is the fastest way to find the DEFAULT that is out of place.
  2. Identify which context DEFAULT appears in. The keyword is legal in only a few places: an INSERT statement's VALUES clause, an INSERT ... SELECT with a column list, and a DEFAULT constraint's definition on the right side of the constraint (for example CONSTRAINT DF_Status DEFAULT 'New'). It is not legal inside a SELECT list, a WHERE clause, a function call, a CHECK constraint, or a parameter list in a procedure header.
  3. Fix a DEFAULT constraint that repeats the keyword. A common mistake is writing ALTER TABLE Orders ADD Status varchar(20) DEFAULT DEFAULT 'New' or ... DEFAULT (DEFAULT). The correct form is ALTER TABLE Orders ADD Status varchar(20) NOT NULL CONSTRAINT DF_Orders_Status DEFAULT 'New'. The word DEFAULT appears once, followed directly by the value or expression in parentheses.
  4. Fix a DEFAULT used in a SELECT or WHERE clause. If you wrote SELECT DEFAULT FROM Orders or WHERE Status = DEFAULT, replace it with the actual value or column name. DEFAULT is not a value you can read; it only tells INSERT what to supply when a column is omitted.
  5. Fix a stored procedure parameter. In a procedure header you assign a default with = value, not with the word DEFAULT. Write CREATE PROCEDURE dbo.GetOrders @Status varchar(20) = 'New' AS ... and call it with EXEC dbo.GetOrders to use the default, or EXEC dbo.GetOrders @Status = 'Shipped' to override it.
  6. Fix an INSERT that mixes DEFAULT with a value. In a VALUES list you may write DEFAULT in place of a literal for a column that has a default constraint, but you cannot combine it with a value in the same position. For example INSERT INTO Orders (Status) VALUES (DEFAULT) is valid only if Status has a default constraint; otherwise supply a literal. If you meant to insert the string 'DEFAULT', quote it: VALUES ('DEFAULT').
  7. Re-run the corrected statement. Execute just the fixed batch, not the whole script, to confirm the error is gone. If the error persists, check for a second occurrence of DEFAULT elsewhere in the same batch — SQL Server reports only the first one it hits.
  8. Save and version the fix. Update the source script or migration file so the same error does not return on the next deployment. If the statement lives in an application's inline SQL, update that code path as well.

Common Mistakes

  • Doubling the keyword. Writing DEFAULT DEFAULT or DEFAULT (DEFAULT) in a constraint definition is the single most frequent cause of error 1009.
  • Confusing a default constraint with a default parameter. Constraints use the DEFAULT keyword; procedure and function parameters use = value. Mixing the two produces the error.
  • Quoting the keyword. 'DEFAULT' is a string literal, not the keyword. If you meant the keyword, remove the quotes; if you meant the text, keep them.
  • Using DEFAULT in a CHECK constraint or computed column. Neither accepts it. A CHECK constraint must test a real expression; a computed column must use a formula.
  • Assuming the error names the right statement. In a large batch, the reported line can be the start of the batch rather than the exact token. Search the batch for every occurrence of DEFAULT before assuming you have fixed it.

Tips

  • Name your default constraints explicitly (for example DF_Orders_Status) so you can find and drop them later with a predictable name instead of a system-generated one.
  • Keep the keyword in uppercase and the value in parentheses when the value is an expression, such as DEFAULT (GETDATE()). Literal strings and numbers can go without parentheses, but parentheses are always safe.
  • Use sp_helpconstraint 'dbo.Orders' to list existing default constraints on a table before adding a new one, which avoids duplicate or conflicting defaults.
  • When testing a fix, run it inside a transaction and roll back if needed: BEGIN TRAN; ... ROLLBACK; so a mistaken ALTER does not leave the table changed.
  • If your application builds SQL dynamically, log the generated statement. The error often comes from a template that inserts DEFAULT into a position where a value belongs.

Troubleshooting

If the error still appears after you remove the obvious DEFAULT, work through these checks in order. First, confirm you are editing the same database and schema the error came from; a second copy of the procedure or table in another schema can be the real culprit. Second, check for nested statements — a view, function or trigger called by your statement may contain the bad DEFAULT, and the error will surface when the outer statement runs. Third, use OBJECT_DEFINITION(OBJECT_ID('dbo.YourObject')) to print the stored definition and search it for DEFAULT. Fourth, if the statement comes from an ORM or reporting tool, inspect the generated SQL rather than your own code. Finally, if you cannot find the token at all, isolate it by running the batch one statement at a time until the error reproduces; that narrows the location quickly. If the object is encrypted or you lack permission to view its definition, ask the database owner to check it rather than guessing.

Frequently Asked Questions

Where is the DEFAULT keyword actually allowed in SQL Server?

In a DEFAULT constraint definition, in the VALUES clause of an INSERT statement, and in an INSERT with a column list where you want the column's default applied. It is not allowed in SELECT lists, WHERE clauses, CHECK constraints, or procedure parameter lists.

Why does my CREATE PROCEDURE fail with error 1009?

You likely wrote @Param varchar(20) DEFAULT 'x'. Procedure parameters use an equals sign: @Param varchar(20) = 'x'. Change it and the error goes away.

Can I insert the literal text "DEFAULT" into a column?

Yes, but you must quote it: INSERT INTO t (c) VALUES ('DEFAULT'). Unquoted, SQL Server treats it as the keyword and tries to apply the column's default instead.

Does error 1009 mean my table is corrupted?

No. It is a syntax and context error in the statement you ran. The table and data are unaffected; only the statement needs correcting.

Why does the error point to a line that looks fine?

In a multi-statement batch, the reported line can be the batch start rather than the exact token. Search the whole batch for DEFAULT and fix every occurrence.

Can a default constraint call a function?

Yes, for deterministic expressions and some system functions such as GETDATE(). Wrap the expression in parentheses, for example DEFAULT (GETDATE()), and avoid user-defined functions that are not allowed in this context.