After working with an ESRI representative, we found there were orphan domains in the geodatabase.
The procedure below details how to generate a list of orphaned domains for a geodatabase. To eliminate uncertainty, it’s best to remove all domains from every feature class and table and then delete all domains using arcatalog/arcpy. After this is done, we check in SQL again for any remaining domains and delete them to ensure there is nothing left.
1.) Select all domains currently in geodatabase using SQL:
SELECT *
FROM [sde].[GDB_ITEMS]
Where Type = '8C368B12-A12E-4C7E-9638-C9C64E69E98F'
2.) Compare the SQL domains with the arcpy domains:
gdb = r'YourGeodatabasePath'
arcpy.env.workspace = gdb
domains = arcpy.da.ListDomains()
sqlDomains = ('List of domains generated in SQL')
stringDomains = []
for domain in domains:
stringDomains.append(str(domain.name))
for domain in sqlDomains:
if domain not in stringDomains:
print domain
To remove and delete all domains in arcpy/arccatalog:
## Removing & deleting all domains in a gdb
import arcpy, traceback
gdb = r'YourGeodatabasePath'
arcpy.env.workspace = gdb
desc = arcpy.Describe(gdb)
for child in desc.children:
if child.dataType in ['Table','FeatureClass']:
for field in child.fields:
if field.domain:
item = child.name
try:
arcpy.RemoveDomainFromField_management(item, field.name)
except arcpy.ExecuteError as e:
print("*** Remove Domain From Field *** arcpy.ExecuteError ***")
print(e.message)
print(traceback.format_exc())
domains = arcpy.da.ListDomains(gdb)
for domain in domains:
arcpy.DeleteDomain_management(gdb, domain.name)