sql server - MS SQL Identity Column Not Counting Correctly on Identity Column -
this question has answer here:
i using ms sql server. please tell me why identity column in database did crazy jump in numbers when supposed auto increment 1 automatically? first off have been entering data in row row. after maybe 100 entries place them not in order sticking 101 right after 31 not in order. of sudden has jumped 290's 1400's when should still in order.... management tools still show right number of entries makes no sense how supposed counting one. please explain me?
<cfif structkeyexists(form, "user_pass")> <!--- form has been submitted ---> <cffile action = "upload" filefield = "filefieldname" destination = "#expandpath("/webapps/dash/images/")#" nameconflict = "makeunique" result = "myfile" /> <cfset imagepath = myfile.serverdirectory & "/" & myfile.serverfile> <cfif isimagefile(imagepath)> <cfquery datasource="test" name="userregistration"> insert dbo.users (employee_number, user_name, user_pass, firstname, lastname, position, email, phone_extension, branch, department, status, picture, admin) values ( <cfqueryparam value='#form.employee_number#' cfsqltype='cf_sql_varchar' /> , <cfqueryparam value='#form.user_name#' cfsqltype='cf_sql_varchar' /> , <cfqueryparam value='#form.user_pass#' cfsqltype='cf_sql_varchar' /> , <cfqueryparam value='#form.firstname#' cfsqltype='cf_sql_varchar' /> , <cfqueryparam value='#form.lastname#' cfsqltype='cf_sql_varchar' /> , <cfqueryparam value='#form.position#' cfsqltype='cf_sql_varchar' /> , <cfqueryparam value='#form.email#' cfsqltype='cf_sql_varchar' /> , <cfqueryparam value='#form.phone_extension#' cfsqltype='cf_sql_varchar' /> , <cfqueryparam value='desoto' cfsqltype='cf_sql_varchar' /> , <cfqueryparam value='#form.department#' cfsqltype='cf_sql_varchar' /> , <cfqueryparam value='active' cfsqltype='cf_sql_varchar' /> , <cfqueryparam value='#myfile.serverfile#' cfsqltype='cf_sql_varchar' /> , <cfqueryparam value='no' cfsqltype='cf_sql_varchar' /> ) </cfquery> <script> self.location="../login.cfm"; </script> <cfelse> <script> <!--- not image file return kind of validation message... ---> alert("not image file"); self.location="../register.cfm"; </script> </cfif> </cfif>
the numbers guaranteed monotonically increasing, not adjacent. here relevant documentation.
in general, identity columns constrained unique or primary keys. however, not guaranteed unique without these constraints.
they increase. , weird behavior efficiency, particularly in parallel systems.
it easy enough sequential value no gaps, if need it, @ query time:
select row_number() on (order id) sequential_with_no_gaps
Comments
Post a Comment