1、 通过@@identity获取插入数据的ID
insert into [table](ID,name) values(@ID,@name);select @@identity
通过ExecuteScalar 获取的值就是ID
2、通过output inserted
insert into table ouput inserted.id values()
这个会返回插入数据的指定列的值 如获取ID 就是output inserted.ID
1、 通过@@identity获取插入数据的ID
insert into [table](ID,name) values(@ID,@name);select @@identity
通过ExecuteScalar 获取的值就是ID
2、通过output inserted
insert into table ouput inserted.id values()