Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL update
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
Versions des environnements
SQL Server:
SQL Server 2005
Application:
Desktop
Divers
Thread ID:
01379140
Message ID:
01379153
Vues:
22
>Update Table_Inv Set QTY = QTY + TABLE_DETAILS.Qty from Table_Inv INNER JOIN Table_Details ON Table_Inv.Code = Table_Details.Code


Try it :-)
DECLARE @Test  TABLE (Id int, Qty Int)
DECLARE @Test1 TABLE (Id int, Qty Int)



INSERT INTO @Test VALUES (1, 10)

INSERT INTO @Test1 VALUES (1, 50)
INSERT INTO @Test1 VALUES (1, 60)


UPDATE Test SET Test.Qty = Test.Qty + Test1.Qty
FROM @Test Test
INNER JOIN @Test1 Test1 ON Test.Id = Test1.Id


SELECT * FROM @Test ---- Qty = 70 HA!!!!
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform