Skip to content
Microsoft SQL Server

SQL Server Error 201

Procedure or function expects a parameter which was not supplied

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 201, Level 16, State 4, Procedure dbo.GetCustomerOrders, Line 0
Procedure or function 'GetCustomerOrders' expects parameter '@CustomerId', which was not supplied.
Other forms of this message
sqlcmd (prints the error number in hex: 0xC9 is 201)
HResult 0xC9, Level 16, State 4
Procedure or function 'GetCustomerOrders' expects parameter '@CustomerId', which was not supplied.
.NET SqlClient (SqlException.Message; Number 201, Procedure dbo.GetCustomerOrders, LineNumber 0)
Procedure or function 'GetCustomerOrders' expects parameter '@CustomerId', which was not supplied.
Error number
201
Severity
16 (user-correctable error)
State
4
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 201 means a stored procedure (or a function called with EXEC) declares a parameter without a default value, and the call did not pass a value for it.

Every parameter declared without = default is required. When EXEC runs, SQL Server matches the values you passed to the declared parameters, by position or by name, before the procedure body starts. If a required parameter is still empty, the call fails with 201, naming the procedure and the first missing parameter. Line 0 is normal: no statement inside the body has run yet.

The parameter in the message is the one the procedure expected, not the one you typed, which is the key clue when a named argument is misspelled: @CustomerIdentifier = 5 does not reach @CustomerId, so SQL Server reports @CustomerId as not supplied. Passing NULL counts as supplying a value; passing nothing, or the keyword DEFAULT for a parameter that has no default, does not.

Common causes

  • EXEC without any arguments, often from a test call or a job step.
  • A named argument with a different spelling from the declared parameter.
  • A positional call with fewer values than required parameters, for example after a new parameter was added to the procedure.
  • DEFAULT passed for a parameter that has no default value.
  • Application code that sets CommandType to StoredProcedure but never adds the parameter, or adds it under a different name.
  • A scalar function called with EXEC @result = dbo.fn and no arguments. Called inside an expression instead, the same mistake raises error 313 (insufficient number of arguments).

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 the parameters the procedure declares

SELECT p.parameter_id, p.name, TYPE_NAME(p.user_type_id) AS data_type, p.max_length, p.is_output
FROM sys.parameters AS p
WHERE p.object_id = OBJECT_ID(N'dbo.GetCustomerOrders')
ORDER BY p.parameter_id;
What to look for

The exact names and order. Compare them with the call. Note that has_default_value in this view is always 0 for T-SQL procedures, so it cannot tell you which parameters are optional.

Read the definition to see which parameters have defaults

SELECT OBJECT_DEFINITION(OBJECT_ID(N'dbo.GetCustomerOrders')) AS definition;

-- or, split into lines:
EXEC sp_helptext N'dbo.GetCustomerOrders';
What to look for

Parameters written with = value are optional; all others must be passed on every call.

Find other procedures that call it

Useful after adding a required parameter: every caller in the database must be updated too.

SELECT OBJECT_SCHEMA_NAME(d.referencing_id) AS caller_schema, OBJECT_NAME(d.referencing_id) AS caller
FROM sys.sql_expression_dependencies AS d
WHERE d.referenced_id = OBJECT_ID(N'dbo.GetCustomerOrders');
What to look for

Each module that references the procedure. Calls from applications and jobs are not listed and need a code search.

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.

Pass every required parameter, by name

Client or network side

Named arguments survive changes to the parameter order and make a missing one obvious in review.

EXEC dbo.GetCustomerOrders @CustomerId = 5;

Give the parameter a default when it is truly optional

Changes schema

A parameter declared with a default can be left out. Handle the default inside the body, and add new parameters with a default so existing callers keep working.

CREATE OR ALTER PROCEDURE dbo.GetCustomerOrders
    @CustomerId INT = NULL
AS
    SELECT id, total
    FROM dbo.Orders
    WHERE @CustomerId IS NULL OR CustomerId = @CustomerId;

Add the parameter in application code under the declared name

Client or network side

With CommandType.StoredProcedure, add every required parameter to the command, spelled as in the procedure (@CustomerId). Send DBNull.Value for an intended NULL: a parameter whose value is a .NET null is not sent at all, which leads to this error.

Examples

Calling a procedure without its required parameter

CREATE TABLE dbo.Orders (id INT PRIMARY KEY, CustomerId INT, total DECIMAL(10,2));
GO
CREATE PROCEDURE dbo.GetCustomerOrders
    @CustomerId INT
AS
    SELECT id, total FROM dbo.Orders WHERE CustomerId = @CustomerId;
GO

EXEC dbo.GetCustomerOrders;  -- no value for @CustomerId
Result
Msg 201, Level 16, State 4, Procedure dbo.GetCustomerOrders, Line 0
Procedure or function 'GetCustomerOrders' expects parameter '@CustomerId', which was not supplied.

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

A misspelled named parameter

CREATE TABLE dbo.Orders (id INT PRIMARY KEY, CustomerId INT, total DECIMAL(10,2));
GO
CREATE PROCEDURE dbo.GetCustomerOrders
    @CustomerId INT
AS
    SELECT id, total FROM dbo.Orders WHERE CustomerId = @CustomerId;
GO

-- @CustomerIdentifier is not @CustomerId, so @CustomerId stays empty
EXEC dbo.GetCustomerOrders @CustomerIdentifier = 5;
Result
Msg 201, Level 16, State 4, Procedure dbo.GetCustomerOrders, Line 0
Procedure or function 'GetCustomerOrders' expects parameter '@CustomerId', which was not supplied.

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

A positional call that is one value short

CREATE TABLE dbo.Orders (id INT PRIMARY KEY, CustomerId INT, total DECIMAL(10,2));
GO
CREATE PROCEDURE dbo.AddOrder
    @CustomerId INT,
    @Total      DECIMAL(10,2)
AS
    INSERT INTO dbo.Orders (id, CustomerId, total)
    VALUES (1, @CustomerId, @Total);
GO

EXEC dbo.AddOrder 5;  -- 5 goes to @CustomerId; @Total is missing
Result
Msg 201, Level 16, State 4, Procedure dbo.AddOrder, Line 0
Procedure or function 'AddOrder' expects parameter '@Total', which was not supplied.

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

How to prevent it

Call procedures with named arguments, and when you add a parameter to a procedure that is already in use, give it a default so existing callers do not break. Search application code, jobs and other procedures for callers before you add a required one.

In data access code, build the parameter list from one place (a typed wrapper or the procedure metadata) rather than by hand at each call site. The stored procedures and functions lesson covers declaring and passing parameters.

Common questions

Is passing NULL the same as not passing the parameter?

No. EXEC dbo.GetCustomerOrders @CustomerId = NULL supplies a value and does not raise 201. Leaving the parameter out, or passing DEFAULT when it has no default, raises 201.

Why does sp_executesql say "The parameterized query expects the parameter"?

That is error 8178, the sp_executesql equivalent: a parameter is declared in the second argument but no value is passed for it. Add @name = value after the parameter definition list.

My function call says "insufficient number of arguments" instead. Is that the same problem?

Yes, the cause is the same, but functions used in a SELECT or other expression raise error 313. Error 201 appears for procedures, and for functions called with EXEC.

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.