2

How do I do this in TSQL? : How UPDATE and SELECT at the same time

Community
  • 1
  • 1
user1615362
  • 3,657
  • 9
  • 29
  • 46

2 Answers2

4

The TSQL equivalent of the answer in the linked question would be something like

UPDATE [table]
SET foo=1
OUTPUT INSERTED.*, DELETED.*
WHERE boo=2

In an update statement you can use INSERTED to get the "after" values and DELETED the "before" values.

Martin Smith
  • 438,706
  • 87
  • 741
  • 845
1

You're looking for the OUTPUT clause.

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964