时间:2021-07-01 10:21:17 帮助过:2人阅读
IDENT_INCR 函数 -- 返回表的自动增长值,比如我们希望每次增长1,那这个函数就会返回1.
USE AdventureWorks2012; GO SELECT TABLE_SCHEMA, TABLE_NAME, IDENT_INCR(TABLE_SCHEMA + ‘.‘ + TABLE_NAME) AS IDENT_INCR FROM INFORMATION_SCHEMA.TABLES WHERE IDENT_INCR(TABLE_SCHEMA + ‘.‘ + TABLE_NAME) IS NOT NULL;
IDENT_SEED 函数 -- 自动增长列的初始种子值
USE AdventureWorks2012; GO SELECT TABLE_SCHEMA, TABLE_NAME, IDENT_SEED(TABLE_SCHEMA + ‘.‘ + TABLE_NAME) AS IDENT_SEED FROM INFORMATION_SCHEMA.TABLES WHERE IDENT_SEED(TABLE_SCHEMA + ‘.‘ + TABLE_NAME) IS NOT NULL; GO
IDENT_CURRENT -- 表的IDENTITY列的当前自动增长值
USE AdventureWorks2012; GO SELECT TABLE_SCHEMA, TABLE_NAME, IDENT_CURRENT (TABLE_SCHEMA + ‘.‘ + TABLE_NAME) AS IDENT_SEED FROM INFORMATION_SCHEMA.TABLES WHERE IDENT_CURRENT (TABLE_SCHEMA + ‘.‘ + TABLE_NAME) IS NOT NULL; GO
SCOPE_IDENTITY() -- 当前模块内(存储过程)生成的最大自动增长值
@@IDENTITY -- 当前会话内生成的最大自动增长值
SQL SERVER ->> IDENTITY相关函数
标签: