<?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: Add and Populate OBJECTID Field to SQL View in ArcCatalog in ArcGIS Enterprise Questions</title>
    <link>https://community.esri.com/t5/arcgis-enterprise-questions/add-and-populate-objectid-field-to-sql-view-in/m-p/1153540#M32731</link>
    <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/108031"&gt;@KathrynWesson&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There is one other way (i.e. Window function) that I know you can generate unique ids. That said, I could keep it simple and stupid by simply incrementing oids from each table by some offset number to keep numbers unique in this view.&lt;/P&gt;&lt;LI-CODE lang="sql"&gt;(SELECT OBJECTID, SURV_DATE, SURV_CREW, EXEMPT_COD FROM TR.TR_GIS_ADMIN.CRCP
UNION ALL
SELECT OBJECTID + 1000000 as OBJECTID, SURV_DATE, SURV_CREW, EXEMPT_COD FROM TR.TR_GIS_ADMIN.Flexible
UNION ALL
SELECT OBJECTID + 2000000 as OBJECTID, SURV_DATE, SURV_CREW, EXEMPT_COD FROM TR.TR_GIS_ADMIN.Gravel 
UNION ALL
SaECT OBJECTID + 3000000 as OBJECTID, SURV_DATE, SURV_CREW, EXEMPT_COD FROM TR.TR_GIS_ADMIN.Rigid&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 14 Mar 2022 20:44:53 GMT</pubDate>
    <dc:creator>TanuHoque</dc:creator>
    <dc:date>2022-03-14T20:44:53Z</dc:date>
    <item>
      <title>Add and Populate OBJECTID Field to SQL View in ArcCatalog</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/add-and-populate-objectid-field-to-sql-view-in/m-p/1153478#M32729</link>
      <description>&lt;P&gt;Hi everyone! I could really use some help with this, because I have no idea what I'm doing.&lt;/P&gt;&lt;P&gt;Basically, I'm trying to create a SQL View in ArcCatalog that references four SDE feature classes of various pavement types. They were published as a feature service through ArcGIS Pro to our organization's Portal (e.g. they are hosted on our own servers, but I am not the author of the data) for multiple people to survey in Field Maps. I therefore want the View to be linked in such a way that it automatically "refreshes" to reflect any updates that are made to the parent feature classes.&lt;/P&gt;&lt;P&gt;I was able to create a SQL View through ArcCatalog with the command UNION ALL to grab all records from the parent feature classes. Initially, the total number of records in the View matched the total number of records from all four parent feature classes. However, I noticed today that the View now has 1,241 more records than before. I'm quite sure no one but myself is looking at/making changes to the parent data, and all I've done is delete a single record from one of the parent feature classes to test that updates are translating. So, I'm not sure where this disparity is coming from.&lt;/P&gt;&lt;P&gt;I wonder if I need to "Register with Geodatabase" to get my View to sync up properly. Apparently it needs an OBJECTID field with unique values. Here's where I run into issues; each parent feature class has its own OBJECTID field that starts with 1, so when I run the UNION ALL command on them, the OBJECTID field has duplicate values. How would I go about adding and populating an OBJECTID field with unique and sequential values to my SQL View through ArcCatalog?&lt;/P&gt;&lt;P&gt;Here is what I have so far:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="KathrynWesson_0-1647282754322.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/36278i7B6E98DF49C16211/image-size/medium?v=v2&amp;amp;px=400" role="button" title="KathrynWesson_0-1647282754322.png" alt="KathrynWesson_0-1647282754322.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The highlighted items in the Catalog tree are the four parent feature classes. The first portion of the View Definition seemingly works, but I'm struggling with the last two lines of the command (concerning the new field). How would I adjust my View Definition to add and populate this new unique identifier field?&lt;/P&gt;&lt;P&gt;Any help would be greatly appreciated!&lt;/P&gt;&lt;P&gt;ArcGIS Desktop 10.8.1 - ArcGIS Pro 2.6.1 - Portal for ArcGIS 10.8.1 (production server) - Portal for ArcGIS 10.9.1 (test sever)&lt;/P&gt;</description>
      <pubDate>Mon, 14 Mar 2022 18:57:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/add-and-populate-objectid-field-to-sql-view-in/m-p/1153478#M32729</guid>
      <dc:creator>KathrynWesson</dc:creator>
      <dc:date>2022-03-14T18:57:23Z</dc:date>
    </item>
    <item>
      <title>Re: Add and Populate OBJECTID Field to SQL View in ArcCatalog</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/add-and-populate-objectid-field-to-sql-view-in/m-p/1153540#M32731</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/108031"&gt;@KathrynWesson&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There is one other way (i.e. Window function) that I know you can generate unique ids. That said, I could keep it simple and stupid by simply incrementing oids from each table by some offset number to keep numbers unique in this view.&lt;/P&gt;&lt;LI-CODE lang="sql"&gt;(SELECT OBJECTID, SURV_DATE, SURV_CREW, EXEMPT_COD FROM TR.TR_GIS_ADMIN.CRCP
UNION ALL
SELECT OBJECTID + 1000000 as OBJECTID, SURV_DATE, SURV_CREW, EXEMPT_COD FROM TR.TR_GIS_ADMIN.Flexible
UNION ALL
SELECT OBJECTID + 2000000 as OBJECTID, SURV_DATE, SURV_CREW, EXEMPT_COD FROM TR.TR_GIS_ADMIN.Gravel 
UNION ALL
SaECT OBJECTID + 3000000 as OBJECTID, SURV_DATE, SURV_CREW, EXEMPT_COD FROM TR.TR_GIS_ADMIN.Rigid&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Mar 2022 20:44:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/add-and-populate-objectid-field-to-sql-view-in/m-p/1153540#M32731</guid>
      <dc:creator>TanuHoque</dc:creator>
      <dc:date>2022-03-14T20:44:53Z</dc:date>
    </item>
    <item>
      <title>Re: Add and Populate OBJECTID Field to SQL View in ArcCatalog</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/add-and-populate-objectid-field-to-sql-view-in/m-p/1153589#M32732</link>
      <description>&lt;P&gt;Hi Kathryn,&lt;/P&gt;&lt;P&gt;I use something like this to create objectids.&amp;nbsp; This is from sqlserver&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;cast(row_number() OVER (ORDER BY gis.water_valves.asset_id) AS int) AS objectid,&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In relation to you seeing more features than should be there, make sure that the feature classes aren't registered as versioned etc because if they are then you would need to use the &amp;lt;tablename&amp;gt;_evw views instead of the the base table name in the SQL.&amp;nbsp; The _evw view is where it joins the adds and deletes tables with the base table all back together to give the "real/current" picture of the feature class.&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Steve&lt;/P&gt;</description>
      <pubDate>Mon, 14 Mar 2022 22:42:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/add-and-populate-objectid-field-to-sql-view-in/m-p/1153589#M32732</guid>
      <dc:creator>StevenBowden</dc:creator>
      <dc:date>2022-03-14T22:42:00Z</dc:date>
    </item>
    <item>
      <title>Re: Add and Populate OBJECTID Field to SQL View in ArcCatalog</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/add-and-populate-objectid-field-to-sql-view-in/m-p/1161787#M32893</link>
      <description>&lt;P&gt;So simple, and yet, I didn't even think to do this! Thank you. It worked like a charm!&lt;/P&gt;</description>
      <pubDate>Wed, 06 Apr 2022 19:14:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/add-and-populate-objectid-field-to-sql-view-in/m-p/1161787#M32893</guid>
      <dc:creator>KathrynWesson</dc:creator>
      <dc:date>2022-04-06T19:14:42Z</dc:date>
    </item>
    <item>
      <title>Re: Add and Populate OBJECTID Field to SQL View in ArcCatalog</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/add-and-populate-objectid-field-to-sql-view-in/m-p/1161792#M32894</link>
      <description>&lt;P&gt;Wow, my Google-ing never led me to _EVW but your advice worked perfectly! In case anyone else stumbles across this post, here is my working View Definition, which also incorporates &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/2620"&gt;@TanuHoque&lt;/a&gt;'s&amp;nbsp;suggestion:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="sql"&gt;(SELECT OBJECTID + 1000000 as OBJECTID, Length, SURV_DATE, SURV_CREW, EXEMPT_COD
FROM TR.TR_ADMIN.CRCP_EVW
UNION
SELECT OBJECTID + 2000000 as OBJECTID, Length, SURV_DATE, SURV_CREW, EXEMPT_COD
FROM TR.TR_ADMIN.Flexible_EVW
UNION
SELECT OBJECTID + 3000000 as OBJECTID, Length, SURV_DATE, SURV_CREW, EXEMPT_COD
FROM TR.TR_ADMIN.Gravel_EVW
UNION
SELECT OBJECTID + 4000000 as OBJECTID, Length, SURV_DATE, SURV_CREW, EXEMPT_COD
FROM TR.TR_ADMIN.Rigid_EVW)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help!&lt;/P&gt;</description>
      <pubDate>Wed, 06 Apr 2022 19:21:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/add-and-populate-objectid-field-to-sql-view-in/m-p/1161792#M32894</guid>
      <dc:creator>KathrynWesson</dc:creator>
      <dc:date>2022-04-06T19:21:38Z</dc:date>
    </item>
    <item>
      <title>Re: Add and Populate OBJECTID Field to SQL View in ArcCatalog</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-questions/add-and-populate-objectid-field-to-sql-view-in/m-p/1161919#M32897</link>
      <description>&lt;P&gt;I'm glad that it worked.&lt;/P&gt;&lt;P&gt;Just for folks who might come across this post in future. The suggestion that &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/165046"&gt;@StevenBowden&lt;/a&gt; mentioned would work as well. This is the one I briefly mentioned in my very comment with 'sql windowing function'.&lt;/P&gt;&lt;P&gt;The difference between these two solutions are (&lt;EM&gt;as far as I can think of&lt;/EM&gt;&lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;The windowing function gives you unique (mostly sequential and without any gaps) id.&lt;UL&gt;&lt;LI&gt;FYI: sql windowing functions are very powerful and provides a lot of advanced capabilities&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;That said, you might perform slower especially while processing a lot of records.&lt;UL&gt;&lt;LI&gt;I believe indexing fields used in ORDER BY clause would help&lt;/LI&gt;&lt;LI&gt;also the field(s) you are using in the ORDER BY clause can't produce unique identifier for each row, then you row_number() might not deterministic especially with rows with same values.&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;whereas, the option that provided is brain-dead simple, but you might run into some gaps in objectid... also i don't see any issue in performance&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Apr 2022 01:59:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-questions/add-and-populate-objectid-field-to-sql-view-in/m-p/1161919#M32897</guid>
      <dc:creator>TanuHoque</dc:creator>
      <dc:date>2022-04-07T01:59:38Z</dc:date>
    </item>
  </channel>
</rss>

