there is a difference between how the following code runs on sql2008 and sql2000. in sql 2000 the result is correct( the fetch is normal from the first row to the last row) while in sql 2008 the fetch is showing strange behavior( starts from the last inserted row till the first one. below is the code of the problem where 'area' is any table:
create trigger tr on area for insert as
declare @id int
select @id = id from inserted
print 'trigger: ' + convert(varchar(50), @id)
declare c cursor scroll for select id from inserted order by id
open c
fetch next from c into @id
while @@FETCH_STATUS = 0
begin
print 'cursor id: ' + convert(varchar(50), @id)
fetch next from c into @id
end
close c
deallocate c
below is the result showig in sql 2008 :
trigger: 1828
cursor id: 1837
cursor id: 1836
cursor id: 1835
cursor id: 1834
cursor id: 1833
cursor id: 1832
cursor id: 1831
cursor id: 1830
cursor id: 1829
cursor id: 1828
and the result showing in sql 2000 is :
trigger: 1837
cursor id: 1828
cursor id: 1829
cursor id: 1830
cursor id: 1831
cursor id: 1832
cursor id: 1833
cursor id: 1834
cursor id: 1835
cursor id: 1836
cursor id: 1837