Is This Content Helpful?
We're glad to know this article was helpful.
Why do saved SQL queries fail after the data source for an MXD file is altered using SetDatasource?
Running the ArcCatalog SetDatasource tool on an MXD file does not update expressions to match the new data source. Therefore, when updating an MXD file containing expressions that perform attribute selections based on SQL queries, it is possible the expression will fail due to the fact that different data sources may require different syntax in the SQL expression.
For example, a SQL expression used with a personal geodatabase, such as "[LANDUSE] <> ''", fails when the data source is changed to a file geodatabase or to an ArcSDE geodatabase because the brackets "" are not valid in these data sources. The corrected expression would be "LANDUSE <> ''". In cases such as these, alter the SQL expression's syntax to match the required syntax of the new data source after running the SetDatasource tool on an MXD .