<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Table join on SDE FC in Python? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/table-join-on-sde-fc-in-python/m-p/659336#M51257</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I think what you have there will work, you just need to convert your feature classes to feature layers.&lt;BR /&gt;&lt;BR /&gt;Use arcpy.MakeFeatureLayer(AUSTIN_WWMHOLE,"Manhole") for example, and then just use "Manhole" instead of your feature class for inputs in the other commands.&lt;BR /&gt;&lt;BR /&gt;For your table you might have to use arcpy.MakeTableView to get the join to work as well.&lt;BR /&gt;&lt;BR /&gt;EDIT: The joinfield mentioned above probably won't work because it permanently adds a field...I assume you wouldn't want that for an SDE feature class.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks, I will try that.&amp;nbsp; And you're right, I don't want to permanently add a field... I just want to join them to do the field calculations.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 04 Jan 2012 16:33:23 GMT</pubDate>
    <dc:creator>JeremyRead</dc:creator>
    <dc:date>2012-01-04T16:33:23Z</dc:date>
    <item>
      <title>Table join on SDE FC in Python?</title>
      <link>https://community.esri.com/t5/python-questions/table-join-on-sde-fc-in-python/m-p/659333#M51254</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am simply trying to join a table from an SDE featureclass to another table, then calculate some field values after the join.&amp;nbsp; It is a very simple process, and relatively easy to do in ArcMap itself, but I'm having a really hard time getting it to work in Python.&amp;nbsp; Apparently AddJoin_management will not work for SDE FCs, so what options are there?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
# Import arcpy module
import arcpy

# Local variables:
AUSTIN_WWManhole = "Database Connections\\wwwgisoraold.sde\\AUSTIN.AustinWastewater\\AUSTIN.WWManhole"
IMSV7_COMPSMH = "Database Connections\\Hansen_Tables_Production.odc\\IMSV7.COMPSMH"

# Join tables based on COMPKEY field, only keep matching records
arcpy.AddJoin_management(AUSTIN_WWManhole, "COMPKEY", IMSV7_COMPSMH, "COMPKEY", "KEEP_COMMON")

# Select records where METERED = 'Y'
arcpy.SelectLayerByAttribute_management(AUSTIN_WWManhole, "NEW_SELECTION", "\"IMSV7.METERED\" = 'Y'")

# Calculate METERINDICATOR = "Y" for selected records
arcpy.CalculateField_management(AUSTIN_WWManhole, "AUSTIN.WWManhole.METERINDICATOR", "\"Y\"", "PYTHON_9.3", "")

# Select records where METERED = 'N' and METERINDICATOR = 'Y'
arcpy.SelectLayerByAttribute_management(AUSTIN_WWManhole, "NEW_SELECTION", "\"IMSV7.METERED\" = 'N' AND AUSTIN.WWManhole.METERINDICATOR = 'Y'")

# Calculate METERINDICATOR = "N" for selected records
arcpy.CalculateField_management(AUSTIN_WWManhole, "AUSTIN.WWManhole.METERINDICATOR", "\"N\"", "PYTHON_9.3", "")

print "Complete"
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Jan 2012 14:52:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/table-join-on-sde-fc-in-python/m-p/659333#M51254</guid>
      <dc:creator>JeremyRead</dc:creator>
      <dc:date>2012-01-04T14:52:23Z</dc:date>
    </item>
    <item>
      <title>Re: Table join on SDE FC in Python?</title>
      <link>https://community.esri.com/t5/python-questions/table-join-on-sde-fc-in-python/m-p/659334#M51255</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I usually create a local copy and use arcpy.JoinField_management()&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Jan 2012 15:43:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/table-join-on-sde-fc-in-python/m-p/659334#M51255</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2012-01-04T15:43:10Z</dc:date>
    </item>
    <item>
      <title>Re: Table join on SDE FC in Python?</title>
      <link>https://community.esri.com/t5/python-questions/table-join-on-sde-fc-in-python/m-p/659335#M51256</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I think what you have there will work, you just need to convert your feature classes to feature layers.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Use arcpy.MakeFeatureLayer(AUSTIN_WWMHOLE,"Manhole") for example, and then just use "Manhole" instead of your feature class for inputs in the other commands.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For your table you might have to use arcpy.MakeTableView to get the join to work as well.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;EDIT: The joinfield mentioned above probably won't work because it permanently adds a field...I assume you wouldn't want that for an SDE feature class.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Jan 2012 15:45:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/table-join-on-sde-fc-in-python/m-p/659335#M51256</guid>
      <dc:creator>JeremyLuymes</dc:creator>
      <dc:date>2012-01-04T15:45:07Z</dc:date>
    </item>
    <item>
      <title>Re: Table join on SDE FC in Python?</title>
      <link>https://community.esri.com/t5/python-questions/table-join-on-sde-fc-in-python/m-p/659336#M51257</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I think what you have there will work, you just need to convert your feature classes to feature layers.&lt;BR /&gt;&lt;BR /&gt;Use arcpy.MakeFeatureLayer(AUSTIN_WWMHOLE,"Manhole") for example, and then just use "Manhole" instead of your feature class for inputs in the other commands.&lt;BR /&gt;&lt;BR /&gt;For your table you might have to use arcpy.MakeTableView to get the join to work as well.&lt;BR /&gt;&lt;BR /&gt;EDIT: The joinfield mentioned above probably won't work because it permanently adds a field...I assume you wouldn't want that for an SDE feature class.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks, I will try that.&amp;nbsp; And you're right, I don't want to permanently add a field... I just want to join them to do the field calculations.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Jan 2012 16:33:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/table-join-on-sde-fc-in-python/m-p/659336#M51257</guid>
      <dc:creator>JeremyRead</dc:creator>
      <dc:date>2012-01-04T16:33:23Z</dc:date>
    </item>
    <item>
      <title>Re: Table join on SDE FC in Python?</title>
      <link>https://community.esri.com/t5/python-questions/table-join-on-sde-fc-in-python/m-p/659337#M51258</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Well, I successfully used arcpy.MakeFeatureLayer_management to create the "Manhole" layer, however when I add it as a parameter in arcpy.AddJoin_management it says that "Manhole is not defined."&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also tried making a table view out of WWManhole and still got the same error:&amp;nbsp; "Manhole is not defined".&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Don't understand why it is saying this when I just created it right before running the AddJoin command....&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Jan 2012 18:13:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/table-join-on-sde-fc-in-python/m-p/659337#M51258</guid>
      <dc:creator>JeremyRead</dc:creator>
      <dc:date>2012-01-04T18:13:58Z</dc:date>
    </item>
    <item>
      <title>Re: Table join on SDE FC in Python?</title>
      <link>https://community.esri.com/t5/python-questions/table-join-on-sde-fc-in-python/m-p/659338#M51259</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Are you using quotations around the feature layers/tables. Something like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
# Import arcpy module
import arcpy

# Local variables:
AUSTIN_WWManhole = "Database Connections\\wwwgisoraold.sde\\AUSTIN.AustinWastewater\\AUSTIN.WWManhole"
IMSV7_COMPSMH = "Database Connections\\Hansen_Tables_Production.odc\\IMSV7.COMPSMH"

arcpy.MakeFeatureLayer(AUSTIN_WWManhole,"Manhole")
arcpy.MakeTableView(IMSV7_COMPSMH,"Table")

# Join tables based on COMPKEY field, only keep matching records
arcpy.AddJoin_management("Manhole", "COMPKEY", "Table", "COMPKEY", "KEEP_COMMON")

# Select records where METERED = 'Y'
arcpy.SelectLayerByAttribute_management("Manhole", "NEW_SELECTION", "\"IMSV7.METERED\" = 'Y'")

# Calculate METERINDICATOR = "Y" for selected records
arcpy.CalculateField_management("Manhole", "AUSTIN.WWManhole.METERINDICATOR", "\"Y\"", "PYTHON_9.3", "")

# Select records where METERED = 'N' and METERINDICATOR = 'Y'
arcpy.SelectLayerByAttribute_management("Manhole", "NEW_SELECTION", "\"IMSV7.METERED\" = 'N' AND AUSTIN.WWManhole.METERINDICATOR = 'Y'")

# Calculate METERINDICATOR = "N" for selected records
arcpy.CalculateField_management("Manhole", "AUSTIN.WWManhole.METERINDICATOR", "\"N\"", "PYTHON_9.3", "")

print "Complete"&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 03:53:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/table-join-on-sde-fc-in-python/m-p/659338#M51259</guid>
      <dc:creator>JeremyLuymes</dc:creator>
      <dc:date>2021-12-12T03:53:47Z</dc:date>
    </item>
    <item>
      <title>Re: Table join on SDE FC in Python?</title>
      <link>https://community.esri.com/t5/python-questions/table-join-on-sde-fc-in-python/m-p/659339#M51260</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Nevermind, finally got it to work after a lot of trial and error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# Import arcpy module
import arcpy

# Local variables:
IMSV7_COMPSMH = "C:\\Users\\readj\\AppData\\Roaming\\ESRI\\Desktop10.0\\ArcCatalog\\Hansen_Tables_Production.odc\\IMSV7.COMPSMH"
AUSTIN_WWManhole = "Database Connections\\wwwgisoraold.sde\\AUSTIN.AustinWastewater\\AUSTIN.WWManhole"
WWManhole_View = "WWManhole_View"

print " "
print "Update Meter Indicator Script STARTED: " + str(datetime.datetime.now())
print " "

# Make Table View of WWManhole
arcpy.MakeTableView_management(AUSTIN_WWManhole, WWManhole_View)

# Join tables based on COMPKEY field, only keep matching records
arcpy.AddJoin_management(WWManhole_View, "COMPKEY", IMSV7_COMPSMH, "COMPKEY", "KEEP_COMMON")

print "Tables Joined: " + str(datetime.datetime.now())

# Select records where METERED = 'Y'
arcpy.SelectLayerByAttribute_management(WWManhole_View, "NEW_SELECTION", "METERED = 'Y'")

# Calculate METERINDICATOR = "Y" for selected records
arcpy.CalculateField_management(WWManhole_View, "AUSTIN.WWManhole.METERINDICATOR", "'Y'", "PYTHON")

print "Calculated METERINDICATOR = 'Y': " + str(datetime.datetime.now())

# Select records where METERED = 'N' and METERINDICATOR = 'Y'
arcpy.SelectLayerByAttribute_management(WWManhole_View, "NEW_SELECTION", "METERED = 'N' AND AUSTIN.WWManhole.METERINDICATOR = 'Y'")

# Calculate METERINDICATOR = "N" for selected records
arcpy.CalculateField_management(WWManhole_View, "AUSTIN.WWManhole.METERINDICATOR", "'N'", "PYTHON")

print "Calculated METERINDICATOR = 'N': " + str(datetime.datetime.now())

print " "
print "Update Meter Indicator Script COMPLETED: " + str(datetime.datetime.now())&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 03:53:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/table-join-on-sde-fc-in-python/m-p/659339#M51260</guid>
      <dc:creator>JeremyRead</dc:creator>
      <dc:date>2021-12-12T03:53:50Z</dc:date>
    </item>
  </channel>
</rss>

