Usage of
IDENT_INCR and IDENT_SEED function of
Identity column in sql server
Here we are see how to get
the Increment & Seed Settings of Indentity in the table.
IDENTITY(SEED,INCREMENT)==
IDENTITY(10,5)
Query Snippet:
-- Create
table with identity column
CREATE
TABLE MyOrders2
(
OrderID
int IDENTITY(10,5),
ProductName varchar(20)
);
select
IDENT_INCR('MyOrders2')
-- 5
select
IDENT_SEED
('MyOrders2')
-- 10
drop
table MyOrders2
-- Create
table with identity column
CREATE
TABLE MyOrders2
(
OrderID
int IDENTITY(100,50),
ProductName varchar(20)
);
select
IDENT_INCR('MyOrders2')
-- 50
select
IDENT_SEED
('MyOrders2')
– 100
Try After Reseting the
Indentity by the below command:
It still shows the original
setup in the table not the reset value by “CHECKIDENT”
command.
select
IDENT_INCR('MyOrders2')
-- 50
select
IDENT_SEED
('MyOrders2')
– 100