Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Update multiple rows
Message
 
 
To
13/05/2005 08:16:32
Cristian Tenea
Aquila Part Prod Com
Ploiesti, Romania
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
01013802
Message ID:
01013806
Views:
10
This message has been marked as the solution to the initial question of the thread.
>Hi,
>
>I have 2 tables in SQL server 'ordhead' and 'ordlines' related by idord.
>On relation there are cascading delete from ordhead to ordlines.
>Table ordlines have a trigger for insert, update and delete to update table 'stock' related by idsku.
>When I delete a line from table ordhead, by cascading, all lines from table ordlines are deleted. In delete trigger I receieve the deleted lines in cursor 'deleted'.
>
>In order to update table stock I need to update for all lines from cursor 'deleted'. How to do this? How to write the UPDATE statement?
>

Try
UPDATE StockTable 
  SET InStock = InStock + deleted.qty 
  FROM StockTable JOIN deleted ON deleted.ProductID = StockTable.ProductID 
--sb--
Previous
Reply
Map
View

Click here to load this message in the networking platform