6

I am working on a program to export data from a view containing a geometry type in Sql Server 2008, to an ArcSDE table on another server which also stores data using the geometry type. The source database is not running ArcSDE. This will be a nightly job.

Following the documentation at the link below, I am able to generate an Object ID with every new insert:

http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/in_SQL_Server/006z00000017000000/

My problem (if it is indeed a problem) is before I copy records between the two servers, I first delete all items in target table using a SQL statement:

DELETE FROM target_table_name

However, when I insert the first record after the delete, the ObjectID starts off at the next highest value from before when I deleted the table. For example, lets assume that the highest ObjectID in the table before I deleted it was 1000. After I delete the contents of the table, and start to load new data, the new ObjectID the dbo.i_get_ids stored procedure returns is 1001. Each load has around 100,000 records and since this runs nightly, the ObjectID can become a pretty big value pretty quickly. My question is, is there a way I can reset the value? If I use the following ArcObjects code to truncate the table the ObjectID is reset to zero:

((ITable)targetTable).DeleteSearchedRows(null);

However, if there is a way to do this without ArcObjects, it would be preferred.

PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
asked Mar 13, 2012 at 17:38

1 Answer 1

1

You can run the following command in SQL Management Studio to "reseed" the autonumber:

DBCC CHECKIDENT (target_table_name, RESEED, 1)

http://msdn.microsoft.com/en-us/library/ms176057.aspx

However this could well mess up ArcSDE (I think it is the ArcSDE database you are running it on). You may want to consider using a different key rather than an auto-generated one to reference your records (e.g. to select/update/display as an attribute), and leave the ObjectID alone. Having huge values in this column is not an issue in itself.

answered Mar 14, 2012 at 13:43
3
  • The data being loaded into the new table already has a primary key field. The issue with the ObjectID is just to make ArcSDE happy. I do not use the ObjectID for anything, other than because ArcSDE wants it loaded. Commented Mar 14, 2012 at 14:00
  • The SQL code above should work then. You should be able to execute it through .NET if needed. Commented Mar 14, 2012 at 15:26
  • 1
    The ObjectID does not have an Identity seed on the physical table I am loading data in. The Object IDs are loaded from the "i" tables, which have one record showing the latest ObjectID issued, and some other information that I am not clear on. So it appears that there is no identity seed to reset. Commented Mar 15, 2012 at 14:15

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.