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 2005 Forums
 Transact-SQL (2005)
 call sp inside sp

Author  Topic 

magmo
Aged Yak Warrior

558 Posts

Posted - 2009-03-16 : 09:17:48
Hi

I guess this is a simple task but I need some help to call a sp inside another sp. The sp I would like to call looks like this..


p_UID
@RandomNumber nVarchar (50),
@RandomUID int output


And the actual sp should look something like this..


DECLARE @OrderID int
SET @OrderID = EXEC p_GetUID(@RandomNumber, @RandomUID OUTPUT)

-- some other process

RETURN @OrderID


But I get errors on the set part, so I gues something is wrong with my code.

rohitkumar
Constraint Violating Yak Guru

472 Posts

Posted - 2009-03-16 : 09:28:39
you sure p_GetUID is going to return a single number? make it a function.
Go to Top of Page

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2009-03-16 : 09:43:32
[code]EXEC @OrderID = p_GetUID(@RandomNumber, @RandomUID OUTPUT)[/code]
Go to Top of Page

magmo
Aged Yak Warrior

558 Posts

Posted - 2009-03-16 : 09:50:18
when using this..

@RandomNumber nVarChar(50),
@Adress1 nVarChar(50),
@Adress2 nVarChar(50),
@Adress3 nVarChar(50),
@Adress4 nVarChar(50),
@Adress5 nVarChar(50),
@Adress6 nVarChar(50),
@Adress7 nVarChar(50),
@Adress8 nVarChar(50),
@Adress9 nVarChar(50),
@CustID Int,
@NodeID Int,
@Qty Int,
@FileName nVarChar(100)
AS
BEGIN
SET NOCOUNT ON;

DECLARE @OrderID int
EXEC @OrderID = p_GetUID(@RandomNumber, @RandomUID OUTPUT)

I get this error..

Incorrect syntax near '@RandomNumber'.
Go to Top of Page

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2009-03-16 : 13:44:17
Probably because you have not declared @RandomUID. You will need something like
declare @RandomUID varchar(128);
if the datatype of @RandomUID is varchar(128) in the stored procedure. Also, if the stored procedure expects a value for @RandomUID, you will need to initialize that as well.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-03-16 : 13:49:26
quote:
Originally posted by magmo

when using this..

@RandomNumber nVarChar(50),
@Adress1 nVarChar(50),
@Adress2 nVarChar(50),
@Adress3 nVarChar(50),
@Adress4 nVarChar(50),
@Adress5 nVarChar(50),
@Adress6 nVarChar(50),
@Adress7 nVarChar(50),
@Adress8 nVarChar(50),
@Adress9 nVarChar(50),
@CustID Int,
@NodeID Int,
@Qty Int,
@FileName nVarChar(100)
AS
BEGIN
SET NOCOUNT ON;

DECLARE @OrderID int
EXEC @OrderID = p_GetUID(@RandomNumber, @RandomUID OUTPUT)

I get this error..

Incorrect syntax near '@RandomNumber'.


what does p_GetUID do? does it return a integer value? also the braces are not required

EXEC @OrderID = p_GetUID @RandomNumber, @RandomUID OUTPUT
Go to Top of Page

magmo
Aged Yak Warrior

558 Posts

Posted - 2009-03-16 : 14:49:46
Hi visakh16

It returns a Integer value
Go to Top of Page
   

- Advertisement -