troubleshooting Question

auto incriment

Avatar of m_sudhakar
m_sudhakar asked on
Microsoft SQL Server
7 Comments1 Solution357 ViewsLast Modified:
Why the gaps are occurring in the IDENTITY Property field,  If the insert query fails.

For ex:
Create table JOB ( JOB_id int IDENTITY(1,1) PRIMARY KEY, JOB_Name varchar(50) UNIQUE)

Insert into JOB values (‘Manager’)
Insert it,
Insert into JOB values (‘Manager’)
And again try to insert it gives unique constraint error
Now insert
Insert into JOB values (‘Operator’)

Now check there is a JOB_ID gap between Manager, Operator.
Why this gap is coming? How should I avoid these gaps?
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 7 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros