Skip to main content
Question

Delete features from ArcSDE with a condition

  • Nov 20, 2018 4:23 PM UTC
  • 2 replies
  • 108 views

philippeb
Enthusiast
Forum|alt.badge.img+23

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.

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

2 replies

david_r
Celebrity
  • Nov 20, 2018 4:35 PM UTC

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+23
  • Author
  • Enthusiast
  • Nov 20, 2018 4:52 PM UTC

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!!