0
I need to use a procedure that adds data to the table Pedido
and then on the table ItemPedido
automatically. But I’m not able to create a Procedure work.
Follow my code below:
create procedure [dbo].[add_pedido]
(@codcli int,
@quant varchar(50),
@data date,
@codprod int,
@codpedido int)
as insert into Pedido (CodCli, Data_pedido)
values (@codcli, @data)
insert into ItemPedido (Quant_pedido, CodProduto, CodPedido)
values (@quant, @codprod, @codpedido)
The Request data is entered in the database, but the data for Itempedido is not inserted. To execute, I use the following code:
EXEC add_pedido
@quant = 2, @data = '23/02/2020', @codprod = 4, @codcli = 5, @codpedido = @@IDENTITY;
And I need Itempedido to inherit Codpedido, but I can’t.
Thanks a friend, it worked
– Vinicius Pereira