我们在项目中常常遇到这种情况,,想得到刚刚新插入数据库那条记录的id,语法如下:
INSERT INTO[soloreztest] ([name]) outputinserted.id VALUES (‘solorez’)
例如:
insert into dbo.BIZ_producePlan (planId, produceDate) output inserted.id values (349, ‘2012-11-03 00:00:10’)
执行后返回id,然后可以把这个sql当做查询语句执行,得到返回的id
还深深埋在心底,要除去,怕是不能活命。