// SQL Server error reference

SQL Server error 4121: Cannot find column or function

A call like schema.function() couldn't be resolved to a column method or user-defined function: wrong schema, a typo, or a function that isn't deployed.

Error number
4121
Severity
16
Category
Names and objects
Error message
Cannot find either column "%.*ls" or the user-defined function or aggregate "%.*ls", or the name is ambiguous.

What it means

SQL Server raises 4121 when an expression of the form name.something(...) can't be bound to a column method or a user-defined function or aggregate. Scalar user-defined functions must be called with at least a two-part name such as dbo.MyFunction(), and 4121 usually means that two-part name points at the wrong schema or at a function that doesn't exist there.

Common causes

  • The function exists in another schema or database than the one named.
  • A typo in the function name, or the function wasn't deployed.

How to fix it

  1. Find the function and its schema.

    SELECT SCHEMA_NAME(schema_id) AS schema_name, name, type_desc
    FROM sys.objects WHERE type IN ('FN', 'IF', 'TF', 'FS', 'FT') AND name = N'FormatName';
  2. Call it with the correct schema-qualified name.

    SELECT dbo.FormatName(FirstName, LastName) FROM dbo.People;

Related errors

More names and objects errors

The code and message text are from the Microsoft Database Engine events and errors reference. Browse the full SQL Server error list or search every database error.

// fewer errors, faster fixes

Work on SQL Server in SQLly

A native SQL client for macOS, Windows and Linux with schema-aware IntelliSense, guardrails for risky statements and clear error messages, for SQL Server and the other databases you use.