[GIS] How to insert features in a MS SQL based SDE without giving ObjectID s

enterprise-geodatabasesql server

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]
           ([OBJECTID],[tor]
           ,[value]
           ,[SHAPE])
     VALUES
           (1,dateadd(hour, 11, dateadd(dayofyear, 62 - 1, dateadd(year, 2013 - 1900, 0)))
           ,0.23654
           ,geometry::STGeomFromText('POINT (30000 198572)', 32643))
GO

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)

Best Answer

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 , ...

DG