Home >Database >Mysql Tutorial >得到自增列的下一个会插入的id

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

WBOY
WBOYOriginal
2016-06-07 17:59:331089browse

怎么得到自增列的下一个会插入的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
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn