[1] adaugi în tabela (presupunând că e doar o tabelă) pe care o interoghezi, denumită în continuare TabelaPeştelui,
... where created between getdate()- 1 and getdate() ...
un câmp ID INT IDENTITY(1,1)
[2] creezi o tabelă auxiliară
CREATE TABLE TabelaID (ID INT NOT NULL)
[3] În declanşator adaugi următoarele comenzi T-SQL
...
DECLARE @last_id INT
DECLARE @max_id INT
SET @last_id = ISNULL( (SELECT MAX(ID) FROM TabelaID) , 0 )
SET @max_id = ISNULL( (SELECY MAX(ID) FROM TabelaPeştelui) , 0 )
... from TabelaPeştelui
where (ID BETWEEN @last_id+1 AND @max_id)
AND created between getdate()- 1 and getdate() ...
...
INSERT INTO TabelaID VALUES ( @max_id )