<?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: SQL Connection &amp;amp; Query for versioned data? in Geodatabase Questions</title>
    <link>https://community.esri.com/t5/geodatabase-questions/sql-connection-amp-query-for-versioned-data/m-p/1188757#M7742</link>
    <description>&lt;P&gt;"Base table" does not equal or represent DEFAULT, unless it is not versioned or all the delta tables are empty.&lt;BR /&gt;&lt;BR /&gt;Based on that example above, it could mean that those records have not ever been edited and / or there are still edits that have not compressed.&lt;BR /&gt;&lt;BR /&gt;That would be the best reason to use the versioned view.&lt;/P&gt;</description>
    <pubDate>Fri, 01 Jul 2022 14:53:54 GMT</pubDate>
    <dc:creator>George_Thompson</dc:creator>
    <dc:date>2022-07-01T14:53:54Z</dc:date>
    <item>
      <title>SQL Connection &amp; Query for versioned data?</title>
      <link>https://community.esri.com/t5/geodatabase-questions/sql-connection-amp-query-for-versioned-data/m-p/1188705#M7733</link>
      <description>&lt;P&gt;When making a direct connection to eGDB tables via (for example) SSMS (Management Studio) for a GDB that has (traditional) versioning enabled, I'm querying an old version of the data. &lt;U&gt;The data is post &amp;amp; reconciled to the default version daily.&lt;/U&gt;&lt;/P&gt;&lt;P&gt;If I look at the list of (default/Esri created) views and query against the same table via that view, I see the default version.&lt;/P&gt;&lt;P&gt;I am aware of the Esri created stored procedure for switching versions, &lt;U&gt;but what is the version which querying the table, not via a view?&lt;/U&gt; I cannot see any way to determine which version state this table is other than that (based on editing dates) it is very old.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jul 2022 13:49:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/geodatabase-questions/sql-connection-amp-query-for-versioned-data/m-p/1188705#M7733</guid>
      <dc:creator>ZacharyHart</dc:creator>
      <dc:date>2022-07-01T13:49:26Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Connection &amp; Query for versioned data?</title>
      <link>https://community.esri.com/t5/geodatabase-questions/sql-connection-amp-query-for-versioned-data/m-p/1188725#M7739</link>
      <description>&lt;P&gt;I am not sure you can determine that information based on querying just the base table. There may be edits that have not be compressed and pushed to the base table.&lt;/P&gt;&lt;P&gt;I would not query the base table (directly) to determine anything in terms of "current state" when it is versioned (traditionally).&lt;/P&gt;&lt;P&gt;I hope I am providing a response to your question. If not, let us know.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jul 2022 14:28:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/geodatabase-questions/sql-connection-amp-query-for-versioned-data/m-p/1188725#M7739</guid>
      <dc:creator>George_Thompson</dc:creator>
      <dc:date>2022-07-01T14:28:37Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Connection &amp; Query for versioned data?</title>
      <link>https://community.esri.com/t5/geodatabase-questions/sql-connection-amp-query-for-versioned-data/m-p/1188738#M7741</link>
      <description>&lt;P&gt;so does 'base table' represent the default version of the GDB?&lt;/P&gt;&lt;P&gt;The versions are post &amp;amp; reconciled to the default version daily and and compression is run weekly.&lt;/P&gt;&lt;P&gt;If I query say the top 10 records sorted by 'last_edited_date' descending, i'm seeing stuff from 2019 which would be the inception of this particular GDB.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jul 2022 14:40:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/geodatabase-questions/sql-connection-amp-query-for-versioned-data/m-p/1188738#M7741</guid>
      <dc:creator>ZacharyHart</dc:creator>
      <dc:date>2022-07-01T14:40:31Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Connection &amp; Query for versioned data?</title>
      <link>https://community.esri.com/t5/geodatabase-questions/sql-connection-amp-query-for-versioned-data/m-p/1188757#M7742</link>
      <description>&lt;P&gt;"Base table" does not equal or represent DEFAULT, unless it is not versioned or all the delta tables are empty.&lt;BR /&gt;&lt;BR /&gt;Based on that example above, it could mean that those records have not ever been edited and / or there are still edits that have not compressed.&lt;BR /&gt;&lt;BR /&gt;That would be the best reason to use the versioned view.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jul 2022 14:53:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/geodatabase-questions/sql-connection-amp-query-for-versioned-data/m-p/1188757#M7742</guid>
      <dc:creator>George_Thompson</dc:creator>
      <dc:date>2022-07-01T14:53:54Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Connection &amp; Query for versioned data?</title>
      <link>https://community.esri.com/t5/geodatabase-questions/sql-connection-amp-query-for-versioned-data/m-p/1188778#M7743</link>
      <description>&lt;P&gt;I should perhaps clarify: according to my query, &lt;EM&gt;the most recent edits&lt;/EM&gt; in the base table show as circa 2019. Which would then mean &lt;EM&gt;none of the edits have been compressed&lt;/EM&gt;?&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jul 2022 15:33:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/geodatabase-questions/sql-connection-amp-query-for-versioned-data/m-p/1188778#M7743</guid>
      <dc:creator>ZacharyHart</dc:creator>
      <dc:date>2022-07-01T15:33:04Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Connection &amp; Query for versioned data?</title>
      <link>https://community.esri.com/t5/geodatabase-questions/sql-connection-amp-query-for-versioned-data/m-p/1188807#M7744</link>
      <description>&lt;P&gt;Potentially or those specific records have not be updated since the beginning.&lt;/P&gt;&lt;P&gt;Do you have replicas in the versioning mix or offline copies of the data?&lt;BR /&gt;&lt;BR /&gt;Have you tried the reconcile process with the GP tool (&lt;A href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/reconcile-versions.htm" target="_blank"&gt;https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/reconcile-versions.htm&lt;/A&gt;) and this setting: "Reconcile blocking versions only—Versions that are blocking the target version from compressing will be reconciled. This option uses the recommended reconcile order."?&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jul 2022 16:52:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/geodatabase-questions/sql-connection-amp-query-for-versioned-data/m-p/1188807#M7744</guid>
      <dc:creator>George_Thompson</dc:creator>
      <dc:date>2022-07-01T16:52:58Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Connection &amp; Query for versioned data?</title>
      <link>https://community.esri.com/t5/geodatabase-questions/sql-connection-amp-query-for-versioned-data/m-p/1188820#M7745</link>
      <description>&lt;P&gt;To the first point, what I'm saying is the most recent record in the base table (according to editor tracking) is from&amp;nbsp;&lt;STRONG&gt;2019-09-18 15:23:13.0 &lt;/STRONG&gt;and therefore every other record in that table &lt;U&gt;is older than that&lt;/U&gt;. (And would therefore indicate that the base table has never been updated!?)&lt;/P&gt;&lt;P&gt;An astute guess! We do indeed have offline replicas in the mix here. Everything is configured according to this &lt;A href="https://enterprise.arcgis.com/en/server/latest/publish-services/windows/offline-maps-and-versioned-data.htm" target="_self"&gt;Esri doc here&lt;/A&gt;. The FS is configured to create a version per user. We have a version of the data to control all the field user/offline versions as described in the article and we would most closely resemble 'Workflow 3'&lt;/P&gt;&lt;P&gt;The script responsible for dealing with the versions (using code similar to what is cited in the doc) utilizes the same GP tool you reference.&lt;/P&gt;&lt;P&gt;The code builds a list of versions who's parent version is the DB version I mention above and then reconciles them, and then reconciles the controlling version to the default version. Partial code here:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;verReconcileList = []
#Create a list of children of the Data Inspector version:
for version in versions:
    if version.parentVersionName == inspectionVersion:
        verReconcileList.append(version.name)
        versionName = (version.name.split(".")[1]).split("/")[0]
        lastModified = version.lastModified
        print("{0} Last modified: {1}".format(versionName,lastModified))
    
# Perform maintenance if versions are found, otherwise there is no maintenance to perform.
if len(verReconcileList)&amp;gt;0:
# Get a list of versions from the database
versions = arcpy.da.ListVersions(workspace)        
    
# Reconcile user versions to CollectedFieldData version
    arcpy.ReconcileVersions_management(workspace, "ALL_VERSIONS", inspectionVersion, verReconcileList, "LOCK_ACQUIRED", "NO_ABORT", "BY_OBJECT", "FAVOR_TARGET_VERSION", "POST", "KEEP_VERSION", "c:/temp/reconcilelogCollected.txt")
    # Reconcile CollectedFieldData version to Default version
    arcpy.ReconcileVersions_management(workspace, "ALL_VERSIONS", "sde.DEFAULT", inspectionVersion, "LOCK_ACQUIRED", "NO_ABORT", "BY_OBJECT", "FAVOR_TARGET_VERSION", "POST", "KEEP_VERSION", "c:/temp/reconcilelogDefault.txt")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; In order to control lag between user syncs and making updates visible to web services and GIS staff, this script is run twice a day.&lt;/P&gt;&lt;P&gt;We know it's working because we see the edits in both the 'Inspector' version and the default version.&lt;/P&gt;&lt;P&gt;Everything looks fine in the Esri view of the data table in SSMS as well...just not the base table. To reiterate: looking at the base table, it appears that no records have ever been updated here.&lt;/P&gt;&lt;P&gt;The best compress end state count we can achieve is 61 which isn't too surprising given that Esri's offline data mechanism is apparently prone to creating orphan versions/replicas (according to the Geodata analyst i've worked with in the past).&lt;/P&gt;&lt;P&gt;I just cannot understand how this base table reflects no changes/edits...looks like a snapshot of the data from ~3 years ago....&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jul 2022 17:21:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/geodatabase-questions/sql-connection-amp-query-for-versioned-data/m-p/1188820#M7745</guid>
      <dc:creator>ZacharyHart</dc:creator>
      <dc:date>2022-07-01T17:21:36Z</dc:date>
    </item>
    <item>
      <title>Re: SQL Connection &amp; Query for versioned data?</title>
      <link>https://community.esri.com/t5/geodatabase-questions/sql-connection-amp-query-for-versioned-data/m-p/1188898#M7746</link>
      <description>&lt;P&gt;I bet the replicas are pinning a state and not allowing the edits to be pushed to the base table. Here is a great blog that talks about how to get a better compress with replicas:&amp;nbsp;&lt;A href="https://community.esri.com/t5/esri-technical-support-blog/tips-for-compressing-with-existing-geodatabase/ba-p/898380" target="_blank"&gt;https://community.esri.com/t5/esri-technical-support-blog/tips-for-compressing-with-existing-geodatabase/ba-p/898380&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;I have attached a SQL script (sql_versioning_stats.txt) that will report much of the versioning information. &lt;EM&gt;&lt;U&gt;&lt;STRONG&gt;I recommend that you run this on a TEST / DEV database first&lt;/STRONG&gt;&lt;/U&gt;&lt;/EM&gt;. Is written for SDE schema enterprise geodatabase.&lt;/P&gt;&lt;P&gt;There is also another one (version_inventory.txt) that returns the versions and when they were last touched (edited). It helps in determining if a version is still in use or stale.&lt;BR /&gt;&lt;BR /&gt;I have not run these in a long time, so no promises.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Jul 2022 20:18:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/geodatabase-questions/sql-connection-amp-query-for-versioned-data/m-p/1188898#M7746</guid>
      <dc:creator>George_Thompson</dc:creator>
      <dc:date>2022-07-01T20:18:17Z</dc:date>
    </item>
  </channel>
</rss>

