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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Execute sp from a sp

Author  Topic 

Mannga
Yak Posting Veteran

70 Posts

Posted - 2003-11-21 : 00:47:45
Morning All,

I have the following code which is not working and I am not sure why


Declare @Item As varchar
Declare @Singularity As Int
Declare @ProcessID As Int
Declare @TaskID As Int
Set @Item = (SELECT ItemID FROM CancellationDetails WHERE QryNo = @CTSQryNo)
Set @Singularity = (Exec Frontier..sp_STEP_CreateSingularity 7, 12, @Item, @EmployeeNo)
Set @ProcessID = (Exec Frontier..sp_STEP_StartProcess @Singularity, 1, 4, @EmployeeNo)
Set @TaskID = (Exec Frontier..sp_STEP_GetTasksByProcessID @TaskID)


I am getting an error message saying Incorrect syntax near 'Exec'.

Can anyone see where I am going wrong on this one?

Thanks,
Gavin

ravilobo
Master Smack Fu Yak Hacker

1184 Posts

Posted - 2003-11-21 : 02:22:51
--I think the following code will solve your problem
USE tempdb
GO

CREATE PROCEDURE procTest (@i int output)
AS
BEGIN
RETURN @i+10
END

-- The following code gives the same error which you are getting.
DECLARE @x int
SET @x = (EXEC procTest 10)
PRINT @x

-- This code works fine
DECLARE @x int
EXEC @x = procTest 10
PRINT @x
Go to Top of Page

Mannga
Yak Posting Veteran

70 Posts

Posted - 2003-11-21 : 02:42:02
I see that when you create your SP you set @i as output.

The SP that I am calling was not written by me and I am not allowed to change it and it does not have this type of output. Is there another way around this?

Cheers,
Gavin
Go to Top of Page
   

- Advertisement -