使用方法:select SCOPE_IDENTITY() as ID from [table]select @@IDENTITY as ID from [table]
实例:
sql="SET NOCOUNT ON;insert into [Table](Item) values(‘"&Item&"‘)"sql=sql&";select @@IDENTITY as ID from [Table];SET NOCOUNT OFF;"
在插入某些自增表的时候,需要将其打开:
语法:SET IDENTITY_INSERT TableName ON