I am trying to select the ID of the last inserted value on my database in SQL Server. I tried many ways for example @@IDENTITY
, IDENT_CURRENT('TableName')
, SCOPE_IDENTITY()
but nothing was possible. Also I had tried to order by but nothing worked for me.
In my code I have
Select top(1)*
from Ferramenta_Limpeza
where Ferramenta_ID!='' and (Id_Gestao between'1' and '434')
order by Id_Gestao desc
My logic was to find the value that is diferent of empty, between 1 and 434. The problem is that this, show always the last value even if I insert another record on 'ID =1', this means that I tryed to update the value of Id 1 and when I tryed the same select to show the las value iserted or updated, the code just show me the last row
Can Someone explain how to do it?