Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Call a SP from another SP

Author  Topic 

jggtz
Starting Member

32 Posts

Posted - 2008-06-23 : 11:07:19
MS SQL 2005
I developed several SP that update tables
If I execute them one by one in the SQL Sever Management Studio, they work ok

Now,
I want to execute them all inside another SP
I wrote it (attached code)
Execute it and give me a message that runs successfully but that is not true
May anyone of You tell me the right syntax to do it?

[Code]
USE REPORTES
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE dbo.Astral_sp_Acumula
AS
--
EXECUTE [REPORTES].[dbo].[Astral_sp_AcCpasArtC]
GO
EXECUTE [REPORTES].[dbo].[Astral_sp_AcDevArtC]
GO
EXECUTE [REPORTES].[dbo].[Astral_sp_AcVtasArtV]
GO
-- More sp executions
[Code]

Thanks

JG

jdaman
Constraint Violating Yak Guru

354 Posts

Posted - 2008-06-23 : 11:29:49
Try removing the GO statements when creating the parent sp like so:
USE REPORTES
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE dbo.Astral_sp_Acumula
AS
--
EXECUTE [REPORTES].[dbo].[Astral_sp_AcCpasArtC]
--GO
EXECUTE [REPORTES].[dbo].[Astral_sp_AcDevArtC]
--GO
EXECUTE [REPORTES].[dbo].[Astral_sp_AcVtasArtV]
--GO
-- More sp executions

Read more about the GO statement here to understand better why your original code was not working as you intended: http://msdn.microsoft.com/en-us/library/ms188037.aspx
Go to Top of Page

jggtz
Starting Member

32 Posts

Posted - 2008-06-23 : 14:55:00
Thanks for your reply

The problem seems to be in the SP's I'm trying to Execute
Please look new topic titled 'Stored Procedure syntax problem' submited by me where I explain why I use GO's

JG
Go to Top of Page
   

- Advertisement -