Tuesday, August 26, 2014

View affected rows of UPDATE query

Hello,


With the OUTPUT clause, it offers the same virtual tables "inserted"/"deleted" as a Trigger =>



DECLARE @tbl AS TABLE(id int identity, col1 varchar(20));
INSERT INTO @tbl (col1) VALUES ('Hello');
INSERT INTO @tbl (col1) VALUES ('World');

UPDATE @tbl
SET col1 = col1 + ''
OUTPUT inserted.*





Olaf Helper


[ Blog] [ Xing] [ MVP]

No comments:

Post a Comment