2

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

Community
  • 1
  • 1
user1615362
  • 3,447
  • 9
  • 27
  • 45

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
  • 419,657
  • 83
  • 708
  • 800
1

You're looking for the OUTPUT clause.

SLaks
  • 837,282
  • 173
  • 1,862
  • 1,933