Unable to call stored procedure within stored procedure

Viewed 9417

I have three stored procedures A, B, C

and definition of A is like

StoredProcedure A
As 
Begin

--Some Stuff

Exec DBO.B [Derived Conitions]
Exec DBO.C [Derived Conitions]

END

but whenever I tried to execute the stored procedure A, at parsing time it give waring;

The module 'A' depends on the missing object 'B'. The module will still be created; however, it cannot run successfully until the object exists.
The module 'A' depends on the missing object 'C'. The module will still be created; however, it cannot run successfully until the object exists.

At execution time it throws exception

Could not find stored procedure 'dbo.B'.
Could not find stored procedure 'dbo.C'.

I found so many answers for calling a stored procedure with in stored procedure, but none of them worked for me.

2 Answers

Perhaps, it sounds hilarious but I was getting the mentioned issue as I was using the wrong DB name (for example-Use 'XYZ'). Actually, in my case I was transferring a SP from one environment to another but after doing so I would not change the corresponding DB name .Due to which I was getting the error as the SPs which were involved were present in different DBs in the dissimilar environment.

In nutshell,please check the DB name which should be the very first line of your SP.

For example- Use 'XYZ'.

Related