获取最后插入的id另外方法

在此记录备忘。

CREATE TABLE tb_test(custid INT IDENTITY(1,1) NOT NULL ,
name nvarchar(200) NOT NULL)

DECLARE @cid TABLE(cid INT)

DECLARE @c2 INT

INSERT INTO tb_test(name) 
OUTPUT INSERTED.custid INTO @cid
VALUES('a')

SELECT * FROM @cid c

DROP TABLE tb_test

  

 

posted on 2015-09-28 20:09  感恩的心  阅读(338)  评论(0编辑  收藏  举报

导航