0

I have the next query, but it doesn't update when I have but of a product with the same code in the table detallefacturas

UPDATE dbo.Kardex SET dbo.Kardex.SaldoDocumental = dbo.Kardex.SaldoDocumental + dbo.DetalleFacturas.Cantidad
FROM dbo.Kardex INNER JOIN dbo.DetalleFacturas ON
(dbo.Kardex.CodigoZofriID = dbo.DetalleFacturas.CodigoZofriID) WHERE dbo.DetalleFacturas.FacturaID = @FacturaID

for example.
DetalleFacturas
Item CodigoZofriID Cantidad
1 001-08-000124-001 10
2 001-08-000124-001 20
3 001-08-000222-001 5

Kardex
CodigoZofriID IngresoDocumental SaldoDocumental
001-08-000124-001 400 370
001-08-000222-001 100 95

once made the query this is what see

Kardex
CodigoZofriID IngresoDocumental SaldoDocumental
001-08-000124-001 400 380 BAD
001-08-000222-001 100 100 OK

thanks. Rodrigo.

2
Contributors
1
Reply
3
Views
8 Years
Discussion Span
Last Post by AndrewM001
1

Have you tried:

UPDATE dbo.Kardex
  SET dbo.Kardex.SaldoDocumental = dbo.Kardex.SaldoDocumental + dbo.DetalleFacturas.Cantidad
FROM dbo.DetalleFacturas
WHERE dbo.DetalleFacturas.FacturaID = @FacturaID 
  AND dbo.Kardex.CodigoZofriID = dbo.DetalleFacturas.CodigoZofriID
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.