如何在不插入 SQL Server Management Studio 的情况下获取 auto_increment id?

How to get auto_increment id without insert in SQL Server Management Studio?

据我所知,在 SQL 服务器中查找 AUTO_INCREMENT 值的命令:

SELECT AUTO_INCREMENT
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = DatabaseName
  AND TABLE_NAME = TableName;

但是如果我将以下命令插入 SQL Server Management Studio,则会导致错误

Invalid Column Name "AUTO_INCREMENT"

如何在不向 SQL Server Management Studio 中的 table 插入数据的情况下获取 AUTO_INCREMENT id?

谢谢

如果您想要特定 table 的当前标识值,您可以使用 ident_current():

SELECT IDENT_CURRENT(N'SchemaName.TableName')