Stored procedure is skipping a nested stored procedure

Hello,

When I call the attached stored procedure, EXEC sp_SupportTeamDataInsert is not being executed.  I have performed the following test with these results

In all cases EXEC sp_DistributionTableInsert executes.  However, it looks like EXEC sp_SupportTeamDataInsert is not executed.  When I execute just EXEC sp_SupportTeamDataInsert, that sproc works fine.  This is in a MS SQL Server 2005 environment
ALTER PROCEDURE [dbo].[sp_PopulateDistributionTable]
AS
TRUNCATE TABLE Distribution
BEGIN TRAN
	BEGIN TRY
		EXEC sp_DistributionTableInsert
		EXEC sp_SupportTeamDataInsert
		DELETE FROM Distribution Where LastPostedDate < POPStart 
		DELETE D FROM Distribution D
		INNER JOIN TaskOrderContributions TOC
		ON D.TaskOrder = TOC.TaskOrder
		WHERE TOC.Eligible = 0
		COMMIT TRAN
	END TRY
	
	BEGIN CATCH
		RAISERROR('Transaction Aborted', 16, 1)
		ROLLBACK TRANSACTION
	END CATCH



ALTER PROCEDURE [dbo].[sp_SupportTeamDataInsert]

AS

DECLARE curTaskOrder CURSOR FORWARD_ONLY
FOR SELECT DISTINCT TaskOrder from vwCSIB_ShareAllocationEligibleEmployees
DECLARE @TaskOrder NVARCHAR(50)
OPEN curTaskOrder
FETCH NEXT FROM curTaskOrder INTO @TaskOrder
WHILE @@Fetch_Status = 0
BEGIN
	EXEC spDistributionTableSupportTeamInsert @TaskOrder
	FETCH NEXT FROM curTaskOrder INTO @TaskOrder
END
CLOSE curTaskOrder
DEALLOCATE curTaskOrder 

GO

Open in new window

Juan VelasquezAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

radcaesarCommented:
what happens if you just execute sp_DistributionTableInsert?
roshnipatelCommented:
Try debugging it in pieces:

Run this first to see if it executes..
then add the DELETE STMTS,
then add your TRY CATCH.  

OR you can
execute the whole code block:

TRUNCATE TABLE Distribution
BEGIN TRAN
      BEGIN TRY
            EXEC sp_DistributionTableInsert
            EXEC sp_SupportTeamDataInsert
            DELETE FROM Distribution Where LastPostedDate < POPStart
            DELETE D FROM Distribution D
            INNER JOIN TaskOrderContributions TOC
            ON D.TaskOrder = TOC.TaskOrder
            WHERE TOC.Eligible = 0
            COMMIT TRAN
      END TRY
      
      BEGIN CATCH
            RAISERROR('Transaction Aborted', 16, 1)
            ROLLBACK TRANSACTION
      END CATCH

directly and set breakpoints to verify that it's being called.
ALTER PROCEDURE [dbo].[sp_PopulateDistributionTable]
AS
BEGIN
TRUNCATE TABLE Distribution

		EXEC sp_DistributionTableInsert
Print 'EXEC sp_DistributionTableInsert'
		EXEC sp_SupportTeamDataInsert
Print 'EXEC sp_SupportTeamDataInsert'

END

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Juan VelasquezAuthor Commented:
I found the problem - there was no problem save for staring at the code for two long.
radcaesarCommented:
Please explain the problem clearly.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2005

From novice to tech pro — start learning today.