I have dozens of SQL Server non-spatial database tables. These are common tables, the column types are: nvarchar, int and float.
I try to use Arcpy to automate joining these database tables to shapefiles. The tables have to be registered in ArcGIS first.
The ArcMap I use is 10.3.1. Unfortunately, ArcMap 10.3 doesn't support "sdetable -o register -t" anymore? I tried a while and couldn't make it work.
So, are there other options to automate joining the tables?
Best Answer
You aren't looking for table join automation as much as table registration automation.
It is not necessary to use
sdetable
to register tables with ArcSDE because ArcGIS supports a full "Register with Geodatabase" operation (which does far more than what the command-line utility did).For example, here we have an opened connection:
A right-click and navigation through "Manage" leads to "Register with Geodatabase"
(Note that you can only register as the table owner)
Registration requires a new objectid column, so there may be a prompt:
though if you already have an "ObjectID" column (
INTEGER NOT NULL
) -- which is actually the best option to prevent table fragmentation -- you may get a confirmation prompt instead:And then the table is registered:
The only effective limitation to geodatabase registration is highlighted in the documentation --
and it's possible to use
sdelayer -o register
to at least register spatial views with ArcSDE, which promotes them to "simple feature class" status (without a Query Layer requirement).It is also important to note that once a table is registered with ArcGIS, it has an SDE-set rowid column, which impacts the ability to insert rows outside of ArcGIS, and it should not be altered or dropped with SQL tools (at the risk of geodatabase metadata corruption).
This process can also be accomplished via ArcPy through Register with Geodatabase, as described at the end of the command-line migration page:
Now this: Twenty years ago, shapefiles were pretty wicked, but their time has passed. File geodatabase capabilities exceed those of shapefiles by just about any metric. Joins between file-based geometry sources (.shp or .gdb) and databases are very inefficient, and should be avoided where possible. It sometimes takes a bit of unconventional thinking to work within the limits of native Geometry/Geography types, but there's usually a way to get adequate (and often superior) performance on a database join (and with an enterprise geodatabase, there's always the fallback to SDEBINARY storage).