We Want To Reset Identity Column Then Use Code.If We Delete column By Id Like We delete 5 no id and
After Than we Insert New then We get 6 no Id .We Show Data 1 to 4 id then 6 because 5 no id We Deleted Then Use Code and Get 5 id In Example-
Example-
SELECT * FROM vibha1<Table Name> --Here Vibha1 is TableName
We get Values-
Delete data from table
Ex.
DELETE FROM vibha1 WHERE id=6
One Value Delete then Insert Value
INSERT INTO vibha1(name) VALUES('vibha1')
Get Values-
Then We Use Code
Syntax: DBCC CHECKIDENT( <TableName>, RESEED, <ValuesThen Start>)
And Delete id 7 record
DELETE FROM vibha1 WHERE id=7
Then Execute This
DBCC CHECKIDENT( vibha1 , RESEED, 5)
Then Insert
INSERT INTO vibha1(name) VALUES('vibha1')
Now Get Result
After Than we Insert New then We get 6 no Id .We Show Data 1 to 4 id then 6 because 5 no id We Deleted Then Use Code and Get 5 id In Example-
Example-
SELECT * FROM vibha1<Table Name> --Here Vibha1 is TableName
We get Values-
Delete data from table
Ex.
DELETE FROM vibha1 WHERE id=6
One Value Delete then Insert Value
INSERT INTO vibha1(name) VALUES('vibha1')
Get Values-
Then We Use Code
Syntax: DBCC CHECKIDENT( <TableName>, RESEED, <ValuesThen Start>)
And Delete id 7 record
DELETE FROM vibha1 WHERE id=7
Then Execute This
DBCC CHECKIDENT( vibha1 , RESEED, 5)
Then Insert
INSERT INTO vibha1(name) VALUES('vibha1')
Now Get Result
work this code
ReplyDelete