Skip to main content
Question

Delete features from ArcSDE with a condition

  • November 20, 2018
  • 2 replies
  • 28 views

philippeb
Enthusiast
Forum|alt.badge.img+17

I have an ArcSDE database on SQL Server 2016 and I want to delete features from a condition.

Each night I want to delete thousands of points older than 30 days from now.

My points layer has a datetime2 field (created_date).

I thought using the SQLExecutor to do this and run this script.

DELETE FROM GPSData
WHERE [created_date] < DATEADD(DAY, -30, GETDATE())

Unfortunatly it doesn't work and I don't understand why. The log doesn't say much :

Microsoft SQL Server Spatial Reader: Query failed, possibly due to a malformed statement. Â Query Text `DELETE FROM GPSData
WHERE [created_date] < DATEADD(DAY, -30, GETDATE())'. Provider error `(-2147217871) Query timeout expired'

If I replace DELETE by SELECT *, it works though.

Is there any SQL beast here who would know if it's my query or FME the problem? I don't have access to this SQL Server, so I can't test my query over there.

For sure I could create a procedure straightly in SQL Server, but my FME script is doing a FGDB backup of those points before deleting them.

2 replies

david_r
Evangelist
  • November 20, 2018

The error message says "query timeout expired", so my guess is that the delete statement takes longer than the default 30 second timeout. You can easily increase it, however:

If the table is huge and the delete statement takes a very long time, consider creating an index on the [created_date] column, that would normally speed it up by quite a lot.


philippeb
Enthusiast
Forum|alt.badge.img+17
  • Author
  • Enthusiast
  • November 20, 2018
david_r wrote:

The error message says "query timeout expired", so my guess is that the delete statement takes longer than the default 30 second timeout. You can easily increase it, however:

If the table is huge and the delete statement takes a very long time, consider creating an index on the [created_date] column, that would normally speed it up by quite a lot.

OMG you are right! I put 3600 seconds and it works! Thanks a lot!!


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings