arcpy.env.addOutputsToMap=False
arcpy.MakeTableView_management("<workspace>\\RDA.DBO.Immediate_Assessment",
"tmp_tbl",where_clause)
arcpy.GetCount_management('tmp_tbl')
If the arcpy.env.addOutputsToMap is set to True, the same code will work.
arcpy.env.addOutputsToMap=True
arcpy.MakeTableView_management("<workspace>\\RDA.DBO.Immediate_Assessment",
"tmp_tbl",where_clause)
arcpy.GetCount_management('tmp_tbl')
What I really want to do is the same as the Python following example, but I don't want to add the temporary layer to the map (the code should not rely on an active map in my case)
import arcpy
arcpy.env.workspace = "C:/data/airport.gdb"
inFeatures = "parcels"
outFeatures = "C:/output/output.gdb/new_parcels"
tempLayer = "parcelsLayer"
expression = arcpy.AddFieldDelimiters(tempLayer, "PARCEL_ID") + " = 'Cemetery'"
arcpy.CopyFeatures_management(inFeatures, outFeatures)
arcpy.MakeFeatureLayer_management(outFeatures, tempLayer)
arcpy.SelectLayerByAttribute_management(tempLayer, "NEW_SELECTION",
expression)
if int(arcpy.GetCount_management(tempLayer)[0]) > 0:
arcpy.DeleteFeatures_management(tempLayer)
the above code is from ESRI help document:
Delete Features—Data Management toolbox | ArcGIS Desktop
So the question is:
Can we make in-memory feature layers or tables without adding them to a map?