SQL 2008 R2 : Could not find stored procedure

15,915

Solution 1

You are probably not in the right database within the query window. There should be a dropdown that shows the current database (possibly master). Choose the database you created the stored procedure in and then try again.

Solution 2

It tough to tell this could happen for several reasons.

  1. you didn't actually execute the create proc when you thought you were

  2. you accidentally executed drop proc

  3. You're not connected to the right DB when you called exec my_procedure

  4. You're using a different log on and it doesn't have access to the procedure

  5. Its in a different schema than your default schema

You could run this to see if you proc is there at all in a given DB (or drop the where to see them all)

   select * 
   from INFORMATION_SCHEMA.ROUTINES 
   where ROUTINE_NAME = 'my_procedure'

That said saving the Procedure Creation Script has no impact on your ability to execute it

Solution 3

Try this:

USE my_database;
EXEC my_procedure;
Share:
15,915
Admin
Author by

Admin

Updated on June 13, 2022

Comments

  • Admin
    Admin almost 2 years

    I am studying the SQL procedure.
    I created a procedure and I execute. I was fine... and. it displayed

    Could not find stored procedure when executed "exec my_procedure"

    I am not really sure the reasons I am getting this error. Did I choose the wrong directory to store the procedure?