I have an insert stored procedure which takes many parameters - 2 of them are @FirstName, @LastName. I also have an update stored procedure which takes many parameters - 2 of them are @FirstName, @LastName.
我有一个插入存储过程,它接受许多参数 - 其中2个是@FirstName,@ LastName。我还有一个更新存储过程,它带有许多参数 - 其中2个是@FirstName,@ LastName。
What I want to do is, from inside the insert SP, when it's done, call the update SP and send to it the @FirstName, @LastName.
我想要做的是,从插入SP内部完成后,调用更新SP并向其发送@FirstName,@ LastName。
I don't know the right syntax to do that; I tried:
我不知道这样做的正确语法;我试过了:
exec LandData_Update @FirstName, @LastName
But I think it's 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? Would I write it like this: EXECUTE LandData_Update @MyFirstName=@FirstName, @MyLastName=@LastName
?
如果我用不同的param名称调用更新sp?比如@MyFirstName,@ MyLastName?我会这样写:EXECUTE LandData_Update @ MyFirstName = @ FirstName,@ MyLastName = @ LastName?
1 个解决方案
#1
14
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.
然后使用新变量。但同样,存储过程并不关心变量的调用。
#1
14
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.
然后使用新变量。但同样,存储过程并不关心变量的调用。