Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

SQL Server Error 1090: Invalid Default for Parameter

· 6 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

SQL Server error 1090 means you passed a value to a stored procedure parameter that is not a valid default. The fix is to check the procedure's parameter list and either remove the invalid default from the CREATE PROCEDURE or ALTER PROCEDURE statement, or correct the value you are supplying. This error almost always appears at the moment you create or alter a procedure, not when you execute it, because the default value itself is malformed. Work through the steps below to identify the exact parameter and correct it.

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 view and alter the procedure (db_owner, db_ddladmin, or ALTER permission on the procedure).
  • The definition of the procedure you are creating or altering, including the full parameter list.
  • A test database where you can safely experiment before changing production code.

Step-by-Step

  1. Confirm the error is about a default, not a missing argument. Error 1090 reads: "The default for parameter '%.*ls' is not valid." It fires when the default value in the procedure header cannot be converted to the parameter's data type. If you see a different error number, such as 201 (missing parameter), you have a different problem and should not follow these steps.
  2. Locate the procedure definition. In SSMS, expand your database, then Programmability > Stored Procedures, right-click the procedure and choose Script Stored Procedure as > CREATE To > New Query Editor Window. If the procedure does not exist yet, open the script you are trying to run. Menu labels can differ slightly by SSMS version and region, but the object explorer path is stable.
  3. Read the parameter list line by line. Look for parameters written as @Name data_type = default_value. Error 1090 points at one of these defaults. Common culprits are a default that does not match the data type, such as @StartDate datetime = 'not-a-date', or a numeric default on a character parameter, such as @Code varchar(10) = 123.
  4. Check the data type of each parameter against its default. A default must be implicitly convertible to the parameter type. For int, use a whole number. For decimal or money, use a numeric literal without quotes. For date, datetime or datetime2, use a string literal in a recognised format such as '20240101' or '2024-01-01'. For bit, use 0 or 1. For varchar or nvarchar, quote the value.
  5. Look for reserved words or missing quotes. A default of = NULL is valid. A default of = '' is valid for character types. A default of = GETDATE() is valid only for date and time types. A default of = 'abc' on an int parameter is not valid and will raise 1090.
  6. Correct the default in the procedure header. Edit the line so the literal matches the type. For example, change @Code varchar(10) = 123 to @Code varchar(10) = '123', or change @StartDate datetime = 'not-a-date' to @StartDate datetime = '2024-01-01'. If the parameter should not have a default, remove the = value portion entirely.
  7. Re-run the CREATE or ALTER statement. If the procedure already exists, use ALTER PROCEDURE with the corrected header. If it is new, use CREATE PROCEDURE. The error should disappear once the default is valid.
  8. Test with and without the parameter. Execute the procedure once omitting the parameter (to exercise the default) and once supplying an explicit value. For example: EXEC dbo.MyProc; then EXEC dbo.MyProc @Code = 'ABC';. Both should run without error.
  9. Deploy the corrected script. Once it works in your test database, apply the same change to any other environments. Keep the corrected script in source control so the invalid default does not reappear.

Common Mistakes

  • Quoting numbers or not quoting strings. @Qty int = '5' may convert, but @Name varchar(20) = 5 is a type mismatch and can trigger 1090. Match the literal style to the type.
  • Using a function that is not allowed as a default. Only certain niladic functions and constants are permitted. GETDATE() works for date types; arbitrary expressions or subqueries do not.
  • Assuming the error is at execution time. Error 1090 is raised when the procedure is compiled, so the fix belongs in the header, not in the EXEC call.
  • Editing the wrong copy of the procedure. In large databases, multiple schemas can hold procedures with the same name. Confirm the schema (for example dbo versus sales) before altering.
  • Leaving an invalid default in a deployment script. If the script is re-run later, the error returns. Fix the source script, not just the live object.

Tips

  • Use NULL as the default when you are unsure and handle the absence of a value inside the procedure body with IS NULL checks.
  • Keep parameter defaults simple: constants and the few allowed functions only.
  • Test the procedure in a development database before altering production, especially if other applications call it.
  • If you use sp_helptext or the object explorer to inspect the procedure, compare the header against the body to make sure the parameter names and types agree.

Troubleshooting

If the error persists after you change the default, re-script the procedure and check whether your ALTER actually applied. A common cause is running the script against the wrong database or schema. Confirm the current database with SELECT DB_NAME(); and the schema with SELECT SCHEMA_NAME(); before re-running.

If the procedure compiles but fails at execution, the problem is likely a different error number, such as 201 or 8144, which relate to missing or extra arguments rather than invalid defaults. Check the message text carefully.

If you cannot alter the procedure because of permissions, ask a database administrator to grant ALTER on the procedure or db_ddladmin in the database. Do not attempt to work around permissions by editing system tables.

If the procedure is called by an application and you cannot change the header immediately, create a wrapper procedure with corrected parameters and point the application at that, then retire the old one after testing.

Frequently Asked Questions

What causes SQL Server error 1090?

The default value declared for a stored procedure parameter cannot be converted to that parameter's data type. For example, a text default on an integer parameter or an unquoted string on a character parameter.

Does error 1090 happen when I run the procedure or when I create it?

It happens when the procedure is created or altered, because SQL Server validates the parameter defaults during compilation. Fix the header, not the EXEC statement.

Can I use GETDATE() as a parameter default?

Yes, for date and time data types. It is one of the functions SQL Server permits as a parameter default. Arbitrary expressions and subqueries are not allowed.

Is NULL a valid default?

Yes. @Param int = NULL is valid for any nullable parameter type and is a safe choice when you are unsure.

Why does the error come back after I fixed it?

Most likely an older deployment script containing the invalid default was re-run, or the ALTER was applied to a different database or schema. Check the script in source control and confirm the target database.

Can I remove the default instead of fixing it?

Yes. Delete the = value portion from the parameter. Callers must then supply a value, or the procedure will raise a missing-parameter error if the parameter is required.