вы можете использовать предложение вывода:
insert into Timeline output inserted.name
SELECT @name, @ts
WHERE NOT EXISTS (SELECT 1 FROM Timeline WHERE name=@name AND ts = @ts);
вы можете сделать это и при обновлении
update Timeline
set name = @name
output deleted.name as OLD_NAME, inserted.name as NEW_NAME
РЕДАКТИРОВАНИЕ:
запустите это, и вы поймете:
create table Timeline(
id int not null primary key identity(1,1),
name varchar(50),
ts varchar(50))
insert into timeline output inserted.ID
values ('first record', 'ts')
--it will show 1
insert into Timeline output inserted.ID
SELECT 'first record', 'ts'
union select 'new record', 'ts'
WHERE NOT EXISTS (SELECT 1 FROM Timeline WHERE name='first record' AND ts = 'ts')
--ir will show 2 because the 1 already exits