Link to home
Start Free TrialLog in
Avatar of rp
rpFlag for Portugal

asked on

Sql Server 2008 Express R2 select max id

I am using select max id in a query (SELECT MAX(id) FROM table), but it gives me the impression that sometimes the value returned is not the last id. What better way to get the last record.
ASKER CERTIFIED SOLUTION
Avatar of Patrick Matthews
Patrick Matthews
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If it is the key column of the table, it is better to configure it as an automaticaly incremental generated number.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi

  Maybe type of Id is problem.
  For example if  type of Id is int or nvarchar sort order is different.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial