I want to insert values into two tables.
The first one looks like this
Recipes
RecipeId (unique and AI)
RecipeName
Method
Discontinued
The second one looks like this
IngredientRecipe
RecipeUniqId (unique and AI)
RecipeId (same as the RecipeId in the Recipes table)
IngredientId
I want to insert a RecipeName and a Method. If I do that the RecipeId gets auto incremented. Than I want to insert three times an ingredient with the RecipeId. Its working for one ingredient.
INSERT INTO Recipes (RecipeName, Method, Discontinued)
OUTPUT INSERTED.RecipeId, '5'
INTO IngredientRecipe(
RecipeId,
IngredientId
)
VALUES ('Potato and Chips', 'Potato and Chips bake everything', 'false');
So what I want is that I can add three times the same RecipeId with a different number for the IngredientId.
How to do this? I use sql server
EDIT:
I use asp.net with c# and an N-tier structure. I use a sql server database