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.

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
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.