I have found that SP2 doesn't execute from within SP1 when SP1 is executed.
Below is the structure of SP1:
ALTER PROCEDURE SP1 AS BEGIN
Declare c1 cursor....
open c1 fetch next from c1 ...
while @@fetch_status = 0 Begin
...
Fetch Next from c1 end
close c1
deallocate c1
exec sp2
end
I see non of the PRINT statement outputs if they are printed in the 'Output window' in SQL Server 2005 management studio as the 'Output Window'is empty.
What happens if you run the Stored Procedure code as a single query? If you put a
PRINT
statement before and after the exec, do you see both outputs?you could use @@error to see if there was an error when executing the previous statement.
I am not sure if it helps you, but from my experience the most popular reasons are:
sp2
gets some parameter which makes itnull
value -- i.e. you build its name from the strings and one of them isnull
.sp2
has some conditions inside and none of them is true, sosp2
executes no code at all -- i.e. one of the parameters is typevarchar
, you pass valueVALUE
, check for it inside, but the real value passed tosp2
isV
(because there are no varchar length defined).sp2
builds query from parameters where one of them isnull
and the whole query becomesnull
too.Do you see any output if you put
PRINT
before and after call ofsp2
?