得到自增列的下一个会插入的id


复制代码 代码如下:

declare @Table_name varchar(60)
set @Table_name = 'Pay_inputpay';
Select so.name Table_name, --表名字
sc.name Iden_Column_name, --自增字段名字
ident_current(so.name) curr_value, --自增字段当前值
ident_incr(so.name) incr_value, --自增字段增长值
ident_seed(so.name) seed_value --自增字段种子值
from sysobjects so
Inner Join syscolumns sc
on so.id = sc.id
and columnproperty(sc.id, sc.name, 'IsIdentity') = 1
Where upper(so.name) = upper(@Table_name)
--@Table_name是传入参数 表名 curr_value这个就是准备插入的id

« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3