2

I've found this reference article talking about how to query a file geodatabase using SQL.

http://resources.arcgis.com/en/help/main/10.2/index.html#/Using_SQL_for_reporting_and_analysis_on_file_geodatabases/018s0000000t000000/

My problem is that it doesn't provide any details of how to to connect SSMS (or other query tool) to the file. Is a driver required? Linked server?

Normally any queries about this result in me directed to ArcSDE. But his article suggests file Geodatabases can be queried by SQL.

1
  • File geodatabases support a subset of the SQL language. But "SQL" does not mean SQL-Server. It is NOT possible to connect to a file geodatabase through a Microsoft SQL client.
    – Vince
    May 28 '15 at 23:07
3

As Vince mentioned, you cannot access Esri file geodatabase from SSMS or any other SQL client. File geodatabase is stored in a proprietary way and there is no SQL interface to access it with.

The help page you found refers to the methods that can be access programmatically with ArcObjects. You cannot supply this kind of query in the Select by Attributes window or in the Query Definition dialog box in ArcMap. Some kind of SQL operators can be executed with arcpy.da.SearchCursor in the sql_clause parameter (for data filtering and aggregating) when accessing file geodatabases.

If you wish to access your file geodatabase with a limited SQL interface, you would need to either use ArcObjects or use File Geodatabase API. Here is an example on How to execute a SQL query on a file geodatabase using the File GDB API for .NET.

3
  • File geodatabases are not "encrypted", just opaque. Even using the FGDB API, there is no provision for making it accessible to SSMS without significant reverse-engineering of Microsoft's SQL-Server server-side protocols.
    – Vince
    May 29 '15 at 12:24
  • I need to protest the adjective "rich" as well. FGDB's SQL implementation is better at 1.4, but it's not "rich" - No views, no stored procedures, no use of the JOIN keyword, no UNION ALL, no spatial operators in SQL expressions... I'd recommend "limited SQL interface".
    – Vince
    May 29 '15 at 14:40
  • @Vince, knowing how long you've been working with databases (btw, I was once a huge fan of your se_toolkit), I have happily edited my answer :) May 29 '15 at 15:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.