Create a stored procedure based on stored procedure or combine into one?
Posted on 2014-10-15
Using one or more stored procedures I want to insert a number of record from table A into table B but I want to only insert records from table A that match 2 variables x and y. Then along with the resulting list I want to insert against each record another variable (the same for each record) z.
Select column1, column2, column3, column4 FROM A WHERE column1 = x AND column2 = y
then using the output of above -
INSERT INTO B column1, column2, column3, column4, z
I want to be able to call this procedure by specifying x, y and z in one go.
Should I have two stored procedures (one for the Select and the second for the insert) or can it be done with one stored procedure?
Can anyone supply the code if it can be done with one?