Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL update
Message
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Title:
Environment versions
SQL Server:
SQL Server 2005
Application:
Desktop
Miscellaneous
Thread ID:
01379140
Message ID:
01379153
Views:
21
>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.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform