select top 1 * from yourtable order by id descorselect * from yourtable where id=(select max(id) from yourtable)
如果有主键的话,可以: declare @max select @max = max(主键) from 表名 select * from 表名 where 主键名=@max 如果没有,可以: alter table 表名 add id int not null identity select top 1 * from 表名 order by id desc
1. 降序取最大值的记录 select top 1 * from 你的表 order by 字段名2.直接取最大值 select * from 你的表 where id=(select max(id) from 你的表)
declare @max
select @max = max(主键) from 表名
select * from 表名 where 主键名=@max
如果没有,可以:
alter table 表名 add id int not null identity
select top 1 * from 表名 order by id desc
降序取最大值的记录
select top 1 * from 你的表 order by 字段名2.直接取最大值
select * from 你的表 where id=(select max(id) from 你的表)