数据库教程:得到自增列的下一个会插入的id

复制代码 代码如下:declare @table_name varchar(60) set @table_name = ‘pay_inputpay’; select so.

复制代码 代码如下:
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

本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

ctvol管理联系方式QQ:251552304

本文章地址:https://www.ctvol.com/dtteaching/619099.html

(0)
上一篇 2021年5月22日
下一篇 2021年5月22日

精彩推荐