Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to load features into ArcSDE without using ArcObjects, and using SQL from my .NET Application instead.

I have followed the answers given in this question: Is it possible to load features into ArcSDE without using ArcObjects?

The Only problem, is that in the insert SQL Statement, I have to give the objectID, like this:

INSERT INTO [mydatabase].[dbo].[DATAPTS]
           (1,dateadd(hour, 11, dateadd(dayofyear, 62 - 1, dateadd(year, 2013 - 1900, 0)))
           ,geometry::STGeomFromText('POINT (30000 198572)', 32643))

Is this the best way to give the object Id?
Or is there any way to get SQL Server to auto increment this field?

(The second looks impossible, because the Featureclass created by ArcGIS in the SDE, has int as the OBJECTID, and you can't Add identity to an existing column)

share|improve this question

Get the max ObjectID value from the table first, add one to that and use the result in your insert statement.

values ((select MAX(OBJECTID) from [dbo].[DATAPTS]) + 1 , ...


share|improve this answer
That is exactly what I am doing now; But I wonder if there is a better way to do this. – Devdatta Tengshe May 14 '13 at 6:43
As you stated, the feature table does not auto increment the ObjectID field so you have to manually set a unique value when you insert in SQL. The MAX aggregate is a very fast SQL operation especially since OBJECTID is a primary indexed key. I think in ArcGIS Desktop, the ArcObjects code that adds records to a feature class is doing a similar operation. I would think the SQL MAX aggregate would be faster than ArcObjects at determining the max value. – DLG May 14 '13 at 7:48

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.