If I understand your question what you want is to create a file with the insert statements that would undo a delete. If so one way to do this that should work is this:
-- set up some test data
DECLARE @table1 TABLE (id INT, name VARCHAR(32))
INSERT INTO @table1 VALUES (1, 'Fred'),(2, 'Tom'),(3, 'Sally'),(4, 'Alice')
-- drop and create a temporary table to hold the statements to output
IF OBJECT_ID('TempOutputTable', 'U') IS NOT NULL
DROP TABLE TempOutputTable
CREATE TABLE TempOutputTable (SqlStatement VARCHAR(MAX))
-- delete a couple of rows from @table1
DELETE FROM @table1
OUTPUT 'INSERT table1 (id, value) VALUES (' + CAST(deleted.id AS VARCHAR(10)) + ', ''' + deleted.name + ''')' AS SqlStatement
INTO TempOutputTable
WHERE id = 4 OR id = 2
-- export using bcp
DECLARE @SqlCommand sysname
SELECT @SqlCommand = 'bcp "select * from test.dbo.TempOutputTable" queryout D:\mytest.txt -c -T'
EXEC xp_cmdshell @SqlCommand, NO_OUTPUT
-- remove the temporary table
DROP TABLE TempOutputTable
After running this the file D:\mytest.txt
will contain this:
INSERT table1 (id, value) VALUES (2, 'Tom')
INSERT table1 (id, value) VALUES (4, 'Alice')
This assumes that xp_cmdshell
is enabled (to be able to run bcp) and of course you would have to adjust the insert statement according to your needs.