Common SQL Errors

MySQL Error 1305: ER_SP_DOES_NOT_EXIST - How to Fix and Prevent

Galaxy Team
August 6, 2025

MySQL raises error 1305 (ER_SP_DOES_NOT_EXIST) when a stored procedure, function, trigger, or event you attempt to call cannot be found in the selected database.

Sign up for the latest in common SQL errors from the Galaxy Team!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

What is MySQL error 1305?

MySQL Error 1305: ER_SP_DOES_NOT_EXIST means the server cannot locate the requested stored routine or trigger. Confirm the correct database, spelling, and privileges, then recreate or grant access to the object to resolve the issue.

Error Highlights

Typical Error Message

%s %s does not exist

Error Type

Stored Procedure Error

Language

MySQL

Symbol

ER_SP_DOES_NOT_EXIST

Error Code

1305

SQL State

42000

Explanation

Table of Contents

What is MySQL Error 1305 ER_SP_DOES_NOT_EXIST?

Error 1305 signals that MySQL cannot find the stored procedure, function, trigger, or event named in your CALL or EXECUTE statement. The server looks in the current database and the mysql.proc table; if no matching routine exists, it throws ER_SP_DOES_NOT_EXIST.

When does this error appear?

The error surfaces during runtime when you attempt to invoke a routine that was never created, was dropped, resides in another schema, or is hidden by insufficient privileges. It commonly emerges after migrations, refactors, or typos in routine names.

Why is fixing it important?

Unresolved, the error breaks application workflows that depend on stored routines, causing outages, failed deployments, and blocked data pipelines. Prompt resolution restores functionality and guards against cascading failures.

Common Causes

Misspelled routine name

A single character mismatch between the CALL statement and the routine definition leads MySQL to believe the routine is absent.

Wrong database selected

If you switched databases or forgot a USE statement, MySQL searches the wrong schema and cannot find the object.

Routine was dropped or never created

Deployment scripts that skipped or failed the CREATE PROCEDURE step leave no routine to execute, triggering error 1305.

Privilege issues hiding the routine

Users without EXECUTE or TRIGGER privileges cannot see or run the routine, so MySQL responds as if it does not exist.

Related Errors

ER_NO_SUCH_TABLE (Error 1146)

Raised when a referenced table is missing; similar root causes like wrong schema or dropped object.

ER_BAD_DB_ERROR (Error 1049)

Occurs when a specified database does not exist, often preceding error 1305 if the routine is in that missing schema.

ER_CANT_FIND_UDF (Error 1122)

Indicates MySQL cannot locate a user-defined function, paralleling ER_SP_DOES_NOT_EXIST for UDFs.

FAQs

Does case sensitivity affect error 1305?

Yes. On Unix-like systems with lower_case_table_names=0, routine names are case-sensitive. A case mismatch will raise ER_SP_DOES_NOT_EXIST.

Can I call a procedure in another database?

Yes. Prefix the call with the database name: CALL reporting.generate_kpi(); Make sure you have EXECUTE privileges on that routine.

Why does the routine disappear after deployment?

CI pipelines may drop and recreate databases. Ensure migration scripts include CREATE PROCEDURE statements and run in the correct order.

How does Galaxy prevent this error?

Galaxy’s schema explorer and AI autocomplete surface existing routines in the active database, reducing typos and helping you select the right schema before execution.

Start Querying with the Modern SQL Editor Today!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

Check out some other errors

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie Logo
Bauhealth Logo
Truvideo Logo