sql语句如何在insert一条数据后直接返回刚刚插入的数据的ID

来源:互联网 发布:好奇心日报用户量数据 编辑:程序博客网 时间:2024/04/29 23:12

在insert语句之后加上:

           SELECT @@IDENTITY

就可以立即得到之前insert数据的ID

如:

insert into news(newsTitle,newsContent)      values('title','content')select @@identity