all groups > sql server odbc > february 2004 >
You're in the

sql server odbc

group:

IDENTITY Data Type Gaps


IDENTITY Data Type Gaps Paul
2/29/2004 4:51:06 PM
sql server odbc: Hi

We recently upgraded an Access XP database to SQL Server, but continue to use an Access MDB as the front end (more mods need to be done to migrate the front end to an Access Project). In the original Access database, several tables use an Access AutoNumber data type as a primary key. At one point in time, the Access database was converted to a replicated database. Following the conversion, the AutoNumber fields no longer create new values by adding 1 to the previous value; they now use a random number generator. (We converted the database back to a non-replicated format several months prior to converting to SQL Server.

When we converted to SQL, the AutoNumber fields were converted to IDENTITY data type. With a new record, SQL adds to the highest value for a new Identity field value. We've been having a number of "ODBC Time Out", and "Failed insert on linked table" errors when adding records, (the "link fail" errors occur even when the Access form being used to add the new record is based on a single table).

One of the things we've discovered is that some of the random numbers generated by Access during its "replicated" phase are fairly close to the maximum values allowed for the Access AutoNumber data type. (FYI, the Access AutoNumber is a "long integer" data type; more or less equivalent to a SQL Server "int" data type.) One of the tables with frequent problems only has about 25,000 records, but some of its records have primary key values that hover near the limit of the "long int" data type. This has resulted in huge gaps in the numeric values in the new Identity field values. I've tried everything I could find to see if I could force SQL Server to start new Identity field values in some of the lower value gaps, i.e., I tried seeding the Identity field at 27,000, and adding 1 for new records. However, it doesn't work

Is there any way to force SQL Identity values on a table that already has records in it? (It would be OK if we were creating a new table, but we've got thousands of related records to these problematic tables so it'd be a bit tricky to create new Identity field values...although we will probably do this at some point in time.

Any help would be really appreciated. If what I wrote makes no sense, I'm not surprised. I've been working for 16 hours and I'm burnt

THANKS
Re: IDENTITY Data Type Gaps Mary Chipman
3/1/2004 10:17:22 AM
I don't think you're going to have any joy with this app until you get
rid of the identity property on the columns. However, I think you can
do this without messing up existing data.

Since you're working with linked tables with a Jet front-end, this
gives you some flexibility in coding a workaround. One solution would
be to remove the Identity property from the PK columns and write code
to generatenew unique int PK values yourself. One way you could do
this is to base new records on a local Jet table that has the
identical structure as the SQL Server table. All of this data could
get fed to a parameterized stored procedure that created a new record
and generated the new ID, which would be returned to the application
as an output parameter. Code in the stored procedure would create the
pk value based on querying the table to see if a particular value in a
particular range has been used. Wrap all this in an explicit
transaction that only commits once a valid PK in the numeric range
you're looking to fill is created. The new record could then be
dynamically displayed on a form based on the output parameter value in
a WHERE clause in the form's recordsource.

-- Mary
Microsoft Access Developer's Guide to SQL Server
http://www.amazon.com/exec/obidos/ASIN/0672319446

On Sun, 29 Feb 2004 16:51:06 -0800, "Paul"
[quoted text, click to view]
Re: IDENTITY Data Type Gaps squig
3/2/2004 2:38:17 PM
[quoted text, click to view]
use an Access MDB as the front end (more mods need to be done to migrate the
front end to an Access Project). In the original Access database, several
tables use an Access AutoNumber data type as a primary key. At one point in
time, the Access database was converted to a replicated database. Following
the conversion, the AutoNumber fields no longer create new values by adding
1 to the previous value; they now use a random number generator. (We
converted the database back to a non-replicated format several months prior
to converting to SQL Server.)
[quoted text, click to view]
data type. With a new record, SQL adds to the highest value for a new
Identity field value. We've been having a number of "ODBC Time Out", and
"Failed insert on linked table" errors when adding records, (the "link fail"
errors occur even when the Access form being used to add the new record is
based on a single table).
[quoted text, click to view]
generated by Access during its "replicated" phase are fairly close to the
maximum values allowed for the Access AutoNumber data type. (FYI, the
Access AutoNumber is a "long integer" data type; more or less equivalent to
a SQL Server "int" data type.) One of the tables with frequent problems
only has about 25,000 records, but some of its records have primary key
values that hover near the limit of the "long int" data type. This has
resulted in huge gaps in the numeric values in the new Identity field
values. I've tried everything I could find to see if I could force SQL
Server to start new Identity field values in some of the lower value gaps,
i.e., I tried seeding the Identity field at 27,000, and adding 1 for new
records. However, it doesn't work.
[quoted text, click to view]
records in it? (It would be OK if we were creating a new table, but we've
got thousands of related records to these problematic tables so it'd be a
bit tricky to create new Identity field values...although we will probably
do this at some point in time.)
[quoted text, click to view]
See if DBCC CHECKIDENT will help you. You can find the syntax using a
search engine.

Glenn

Re: IDENTITY Data Type Gaps Paul
3/7/2004 4:51:06 PM
Glenn

I'll give this a shot. Thanks for your input! I've been developing Access databases and customizing Office solutions for about 5 or 6 years, but when our company bought out a competitor, I got thrown into the deep end. I'm coming up to speed on SQL Server, but am running into problems partly due to the situation, partly due to inexperience w/ SQL. Little by little, we're gaining ground, but there's much to be done

Thanks again
Re: IDENTITY Data Type Gaps Paul
3/7/2004 4:56:04 PM
Mary

Your idea is an approach that I didn't think of. I'm going to look into this closely. I think it's a great idea and could help us get thru this difficult period. Thanks very much for the input! I'm learning SQL the hard way. I've been doing Access databases and Office customizations for several years, but when our company took over a competing group, I had to dive into the deep end of the SQL Server pool without my Donald Duck life preserver

Thanks much again
Re: IDENTITY Data Type Gaps Mary Chipman
3/9/2004 8:59:26 AM
Well, the newsgroups are a good place to get ideas and info -- good
luck -- the learning curve is indeed a bit steep when you are
attempting to build something more than the most simplistic app.

-- Mary
Microsoft Access Developer's Guide to SQL Server
http://www.amazon.com/exec/obidos/ASIN/0672319446

On Sun, 7 Mar 2004 16:56:04 -0800, "Paul"
[quoted text, click to view]
AddThis Social Bookmark Button