With the IDENT_INCR function we can find the incremental value of the identity column in a table. If there is no Identity column in the table, the result will return NULL.
1 2 3 4 5 6 | USE AdventureWorks2012; GO SELECT IDENT_INCR('[Person].[Person]') AS Incremental_Value GO SELECT IDENT_INCR('[Production].[Product]') AS Incremental_Value GO |
If you want to identify all identity column’s incremental value in the database, you should use the below script:
1 2 3 4 5 6 7 8 9 10 11 | SELECT [Name] = '['+s.name+ +'].['+ t.name+']', IDENT_INCR('['+s.name+ +'].['+ t.name+']') AS Incremental_Value FROM sys.schemas AS s INNER JOIN sys.tables AS t ON s.[schema_id] = t.[schema_id] WHERE EXISTS ( SELECT 1 FROM sys.identity_columns WHERE [object_id] = t.[object_id] ); |