SQL Server error 2812: Could not find stored procedure
The EXEC names a procedure that doesn't exist in the current database or schema, or a string was run as a procedure name by mistake.
- Error number
2812- Severity
- 16
- Category
- Names and objects
What it means
EXEC name looks the procedure up in the current database, first in your default schema and then in dbo (and in master for system procedures whose names start with sp_). If no procedure has that name, you get 2812.
Common causes
- The procedure is in another database or schema and the name isn't qualified.
- A typo, or the procedure wasn't deployed to this environment.
- Running a dynamic SQL string with
EXEC @sqlinstead ofEXEC (@sql): without parentheses SQL Server treats the whole string as a procedure name.
How to fix it
-
Check that the procedure exists and where.
SELECT SCHEMA_NAME(schema_id) AS schema_name, name FROM sys.procedures WHERE name LIKE N'%GetOrders%';
-
Qualify the call with schema (and database if needed).
EXEC SalesDb.Sales.GetOrders @CustomerId = 42;
-
Run dynamic SQL with parentheses, or better with
sp_executesql.DECLARE @sql nvarchar(max) = N'SELECT TOP (5) name FROM sys.objects'; EXEC (@sql); EXEC sys.sp_executesql @sql;
Reproduce it safely
DECLARE @sql nvarchar(100) = N'SELECT 1'; EXEC @sql; -- Msg 2812: Could not find stored procedure 'SELECT 1'.
Related errors
208Invalid object name8144Too many arguments specified8145Is not a parameter for procedure42883PostgreSQL: function does not exist1305MySQL: Function or procedure does not existORA-06550Oracle: PL/SQL compilation error at line, column
More names and objects errors
207Invalid column name4104Multi-part identifier not bound209Ambiguous column name2714There is already an object named3701Cannot drop, object not found3702Cannot drop database, currently in use5030Database couldn't be exclusively locked8146Procedure has no parameters
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.
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.