free_mascot (5/2/2014)
Great Eirikur, is it possible to send this OUTPUT to excel using this T-sql?
Use the output to insert the records into a table and export to excel/csv from there. I added the insert bit to the following code
😎
DECLARE @TTABLE TABLE
(
TT_ID INT IDENTITY(1,1) PRIMARY KEY CLUSTERED NOT NULL
,TT_VAL INT NOT NULL
);
DECLARE @TTDELETED TABLE
(
TT_ID INT PRIMARY KEY CLUSTERED NOT NULL
,TT_VAL INT NOT NULL
);
INSERT INTO @TTABLE(TT_VAL)
VALUES (123),(234),(345),(456),(567);
SELECT * FROM @TTABLE;
DELETE
FROM @TTABLE
OUTPUT deleted.* INTO @TTDELETED(TT_ID,TT_VAL)
WHERE TT_VAL < 300;
SELECT * FROM @TTABLE;
SELECT * FROM @TTDELETED;