7
I would like to return the last value of the primary key entered in the table, but my primary key is CPF
so I can’t use SELECT SCOPE_IDENTITY()
.
7
I would like to return the last value of the primary key entered in the table, but my primary key is CPF
so I can’t use SELECT SCOPE_IDENTITY()
.
7
There isn’t a T-Sql for that. You just use SCOPE_IDENTITY or IDENT_CURRENT as long as the column is Identity.
I recommend the following readings:
An alternative is to add a field DataInsercao
like datetime
the structure of your table. By default
this field should receive the current date, the function GETDATE() could be useful in this case.
So you can sort by most current date and check which last record you entered.
Select should look something like this:
Select top 1 * from MinhaTabela Order By DataInsercao DESC
Browser other questions tagged sql sql-server
You are not signed in. Login or sign up in order to post.