CREATE PROCEDURE sp_recycle
AS
DECLARE @maxid int,@sql varchar(8000)
IF exists(SELECT * FROM t)
BEGIN
  SELECT @maxid=MAX(id) FROM t
  CREATE TABLE #t(id int)
  SET @sql='SELECT TOP '+CAST(@maxid AS varchar)+' IDENTITY(int,1,1) id
              INTO #tem FROM syscolumns a,syscolumns b,syscolumns c
            INSERT #t
              SELECT * FROM #tem
            DROP TABLE #tem '
  EXEC(@sql)
  SELECT id FROM #t WHERE not exists(SELECT * FROM t WHERE id=#t.id)
  DROP TABLE #t
END
GO