Sunday, February 12, 2012

auto increment problem

hi
I am facing problem in auto increment
when i enter to commit the row if data is right then incerment is 1
if enter data is wrong then error shows after correcting error
it increments not by 1 as shows in picture

does auto increment supports numeric(10)
as
id numeric(10) IDENTITY (1, 1),if you make an error while inserting, then that particular number is not re-used

which should not matter to your app (if the gaps in the numbers are a concern, then you are doing something wrong)

yes, you could use NUMERIC(10) for an IDENTITY column, but why would you?

you can also use BIGINT like you are currently using, but unless you know you're going to have more than two billion rows, use INTEGER|||using numeric(10) is need of our project

but just you see in figure when first i enter wrong string then error message come when I enter ok on that message then renter right string then
just see on ID column which is primary key and auto increment but
one time error occors one number scips as in id 17 to 19 not 18
so whats the problem what to do to overcome|||there is no problem, and you don't need to do anything to overcome it

gaps in IDENTITY values are irrelevant|||This is simply how identity columns work in SQL Server (and Sybase for that matter). If you are looking to "overcome" this, you will have to create your own auto-increment functionality. As r937 said, if you can not stand the gaps in the sequence, the application is doing something wrong.|||This is simply how identity columns work in SQL Server (and Sybase for that matter). If you are looking to "overcome" this, you will have to create your own auto-increment functionality. As r937 said, if you can not stand the gaps in the sequence, the application is doing something wrong.

so please can you give an example to create our own autoincrement
how to create ?|||ankur, we advise against creating your own autoincrement

why do you want no gaps in the numbers?|||so please can you give an example to create our own autoincrement
Seeing as I have never had the occasion or inclination to reinvent identity column functionality to support a bad design, no|||ankur, we advise against creating your own autoincrement

why do you want no gaps in the numbers?

because gaps in ID is primary key and gaps in numbers will make inconsistency
so is there some simple way to avoid

but

if we run query explicitly we can fill those gaps

but how can we do in gui mode|||gaps in numbers will make inconsistency

What will be inconsistant?|||inconsistency?

please give an example of where gaps would affect your application, and we will explain why it is a bad design choice|||many moons ago I programmed something with a logical delete process instead of real delete process because some auditor did not like gaps in ids provided by IDENTITY. Other than that, I can not think of any reason this should matter.|||That's not even a good reason :p|||people tell me to do stuff and I get a check every couple of weeks. I was younger.|||you can also use BIGINT like you are currently using, but unless you know you're going to have more than two billion rows, use INTEGER

or more than 2 billion insert errors ;)

No comments:

Post a Comment