Can I run 2 queries in one stored procedure ?
CREATE PROCEDURE AddProd
@Store_Name varchar(50),
@Price int,
@Prod_Name varchar(50),
@Qty int,
@ProductDescription varchar(50),
@RatingSum int,
@RatingCount int,
@ProductImage varchar(50),
@Prod_Date date,
AS
BEGIN
SELECT S.Store_ID
FROM Store S
WHERE StoreName=@StoreName
INSERT INTO Product (Store_ID, Price, Prod_Name, Qty, ProductDescription, RatingSum, RatingCount, ProductImage, Prod_Date)
VALUES (S.Store_ID, @Price, @Prod_Name, @Qty, @ProductDescrpition, @RatingSum, @RatingCount, @ProductImage, @Prod_Date)
END
GO
For this code above, I want retrieve a STORE_ID by giving the STORE_NAME the user give as a parameter.
I want to use this STORE_ID in the INSERT statement.
Can I do this ?!
AKA, is the S.store_ID returned from the first query, the same as that one I used in "Values" ?