We have a script that extracts the data from sde to gdb (newly created upon script execution). It runs through each layer in the sde to create new layers in gdb and sometimes throws an error "ExecuteError: Error 999999: Error executing function. The operation was attempted on an empty geometry. Failed to execute (SelectLayerByLocation)". Is there a way to remove the empty features or repair geometry? SDE automatically does checks the geometry by default but I am still having the problems.
Yes, you could try inserting Repair Geometry in the script (ArcGIS Help 10.1). This sometimes needs to be run a few times consecutively to fully repair the geometry.