views:

339

answers:

1

I have an insert SP which takes many parameters, 2 of them are @FirstName, @LastName.
And have another update SP which takes manay parameters, 2 of them are @FirstName, @LastName.

What i want to do is: from inside the insert SP "at its end", call the update SP and send to it the @FirstName, @LastName.

I don't know the right syntax to do that, i tried:

exec  LandData_Update @FirstName, @LastName

But i think its wrong.

Can someone tell me how to write this calling?

And if i will call the update sp with different param names? such as @MyFirstName, @MyLastName? will write it like that: EXECUTE LandData_Update @MyFirstName=@FirstName, @MyLastName=@LastName ??

+2  A: 

What makes you think it's wrong?

CREATE PROCEDURE MyInsertSP
    @FirstName varchar(255),
    @LastName  varchar(255)
AS
BEGIN
    INSERT INTO Table VALUES('Some Value')

    EXECUTE LandData_Update @FirstName, @LastName
END

Do you get an error or something?

EDIT: It doesn't matter what the name of the variables are, but to do what you want you can declare two new variables.

DECLARE @MyFirstName varchar(255)
DECLARE @MyLastName  varchar(255)

SET @MyFirstName = @FirstName
SET @MyLastName  = @LastName

And then use the new variables. But again, the Store Procedure doesn't care what the variables are called.

Arkain
and if i will call the update sp with different param names? such as @MyFirstName, @MyLastName? will write it like that: EXECUTE LandData_Update @MyFirstName=@FirstName, @MyLastName=@LastName ??
Amr ElGarhy
Yes, that should work finehttp://msdn.microsoft.com/en-us/library/ms188332(SQL.90).aspx
ZippyV