UPDATE with INNER JOIN

Please support our MS SQL advertiser: Intel Parallel Studio Home
Reply

Join Date: Sep 2008
Posts: 1
Reputation: rdneira is an unknown quantity at this point 
Solved Threads: 0
rdneira rdneira is offline Offline
Newbie Poster

UPDATE with INNER JOIN

 
0
  #1
Sep 28th, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 1
Reputation: AndrewM001 is an unknown quantity at this point 
Solved Threads: 0
AndrewM001 AndrewM001 is offline Offline
Newbie Poster
 
1
  #2
Oct 27th, 2009
Have you tried:
  1. UPDATE dbo.Kardex
  2. SET dbo.Kardex.SaldoDocumental = dbo.Kardex.SaldoDocumental + dbo.DetalleFacturas.Cantidad
  3. FROM dbo.DetalleFacturas
  4. WHERE dbo.DetalleFacturas.FacturaID = @FacturaID
  5. AND dbo.Kardex.CodigoZofriID = dbo.DetalleFacturas.CodigoZofriID
Reply With Quote Quick reply to this message  
Reply

Message:



Similar Threads
Other Threads in the MS SQL Forum
Thread Tools Search this Thread



Tag cloud for MS SQL
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC