SQL ServerPostgreSQLMySQL

"Could not find stored procedure" (Msg 2812)

SQL Server resolved the name to nothing — a typo, the wrong schema, the wrong database, or (easy to miss) a single bare word sent as a query, which SQL Server interprets as a procedure call with no EXEC keyword in sight.

  • SQL Server: Msg 2812, Level 16, State 62 followed by Could not find stored procedure 'GetOrderSummary'.
  • PostgreSQL: ERROR: function get_order_summary() does not exist
  • MySQL: ERROR 1305 (42000): PROCEDURE shop.GetOrderSummary does not exist

The cause, in order of how often each one actually happens

A plain typo in the procedure name — check it character by character against sys.procedures rather than trusting memory:

SELECT name, SCHEMA_NAME(schema_id) AS schema_name
FROM sys.procedures
WHERE name LIKE '%OrderSummary%';

The procedure exists, but in a different schema than the one being assumed. Unqualified EXEC GetOrderSummary resolves against the calling session's default schema, not necessarily dbo — if the procedure actually lives in dbo but the login's default schema is something else, the unqualified call fails even though the procedure is right there. Qualify it explicitly to rule this out:

EXEC dbo.GetOrderSummary;

The procedure exists, but in a different database than the one the connection is currently using — cross-database calls need a three-part name, and SQL Server won't search other databases on its own:

EXEC OtherDatabase.dbo.GetOrderSummary;

A single bare word, sent as the entire batch, with no EXEC. This one surprises people: SQL Server specifically interprets a lone identifier as the first token of a batch as a parameterless procedure call, even without EXEC in front of it — so sending just GetOrderSummary as a whole query behaves identically to EXEC GetOrderSummary, and produces exactly this error if the name is wrong, rather than a syntax error. If the query that failed looks like it shouldn't have been trying to call a procedure at all, check whether it's actually a bare single word with nothing else in the batch.

The procedure was created in a different session's tempdb — a common one for #temp-prefixed "scratch" procedures: a local temporary procedure (#GetOrderSummary) only exists for the session that created it, and disappears the moment that session ends. A second session, or a reconnect, genuinely cannot see it — this isn't a naming bug, it's correct, by-design scoping.

A linked-server or cross-instance variant worth knowing about

If the procedure name is correct and it demonstrably exists, but the call still fails this way specifically after moving a database to a new server or restoring it elsewhere, check the calling login's default database on the new server — a login whose default database no longer exists (or was never reset after a migration) can produce this same error for calls that used to work fine, because the connection silently lands somewhere other than where the procedure actually lives.

Can't demonstrate this in the playground

Stored procedures are a server-side object SQL Server (and most server engines) support, but the SQLite sandbox embedded in this page doesn't — SQLite has no CREATE PROCEDURE at all, only regular SQL statements run directly by the application. Reproduce this by calling a deliberately misspelled or wrongly-schema-qualified procedure name against a real SQL Server instance.