How to Call a stored procedure from another stored procedure?

后端 未结 1 1936
名媛妹妹
名媛妹妹 2020-12-31 17:38

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 o

相关标签:
1条回答
  • 2020-12-31 18:11

    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.

    0 讨论(0)
提交回复
热议问题