<?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: Query Layer Won't Retain Attribute Values When Coverted to Table in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/query-layer-won-t-retain-attribute-values-when/m-p/146617#M11441</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I set up an OLE DB connection to the SQl server and set the workspace to a geodatabase. I ran the make query table tool and I got this error:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;000383 : Issue with a table; cannot find the workspace&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;IMG __jive_id="278100" alt="" class="image-1 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/278100_make_query_table.JPG" style="width: 620px; height: 569px;" /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 07 Dec 2016 18:28:59 GMT</pubDate>
    <dc:creator>LloydBronn</dc:creator>
    <dc:date>2016-12-07T18:28:59Z</dc:date>
    <item>
      <title>Query Layer Won't Retain Attribute Values When Coverted to Table</title>
      <link>https://community.esri.com/t5/python-questions/query-layer-won-t-retain-attribute-values-when/m-p/146614#M11438</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So I'm starting to work with ArcGIS and SQL Server. I've successfully made a DB connection in ArcMap and created a query layer. I'm trying to automate this process with Python and I'm aware of the bugs involved and I found this workaround involving arcpy.Describe.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;MakeQueryLayer_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;DB_Conn&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; query_layer&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"SELECT * FROM CMORPH_Test.dbo.cmorph_data WHERE precipmm &amp;gt; 1"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"OBJECTID"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;""&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;""&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; spatial_reference&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
desc &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Describe&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;query_layer&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
query_table &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;TableView&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;desc&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;name&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;CopyRows_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;query_table&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;interim_table&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This creates an info table. The problem is, each one of the records&amp;nbsp;in the SQL server contains a date field (called "day") formatted like this: 19980101. When I open the info table in ArcMap or convert it to a&amp;nbsp;dbf, the date field is now zero.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any ideas why this would happen?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 07:59:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/query-layer-won-t-retain-attribute-values-when/m-p/146614#M11438</guid>
      <dc:creator>LloydBronn</dc:creator>
      <dc:date>2021-12-11T07:59:47Z</dc:date>
    </item>
    <item>
      <title>Re: Query Layer Won't Retain Attribute Values When Coverted to Table</title>
      <link>https://community.esri.com/t5/python-questions/query-layer-won-t-retain-attribute-values-when/m-p/146615#M11439</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Lloyd,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What is the database type of the date field in your RDBMS (the one from which you make the query layer)?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A couple thoughts:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Since you are working with tabular data, try using the &lt;A href="http://pro.arcgis.com/en/pro-app/tool-reference/data-management/make-query-table.htm"&gt;Make Query Table&lt;/A&gt; tool instead of Make Query Layer&lt;/LI&gt;&lt;LI&gt;Try writing your output interim_table to a geodatabase table or directly to .dbf table (just add the .dbf extension)&lt;/LI&gt;&lt;LI&gt;You should be good to copy your Query Table directly to a proper table using CopyRows (no need to make an arcpy mapping table view object first). If there's a bug related to this, please send me some info on it! I'd like to know about that as I teach people about making query layers and query tables from time to time.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck, let me know how it turns out.&lt;/P&gt;&lt;P&gt;Micah&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Dec 2016 23:25:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/query-layer-won-t-retain-attribute-values-when/m-p/146615#M11439</guid>
      <dc:creator>MicahBabinski</dc:creator>
      <dc:date>2016-12-06T23:25:16Z</dc:date>
    </item>
    <item>
      <title>Re: Query Layer Won't Retain Attribute Values When Coverted to Table</title>
      <link>https://community.esri.com/t5/python-questions/query-layer-won-t-retain-attribute-values-when/m-p/146616#M11440</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the response. The database is SQL Express&amp;nbsp;2012. Eventually I'll be working with a full SQL Server database and complex queries after testing. I've also tried writing to a dbf, but the date field also becomes zero. I'll try creating a query table instead.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My end result is to make a map service that will be hosted on our ArcGIS Server. Users will be able to click on features and return results of queries directly from the SQL database. This sample data I'm working with will be points. The data in SQL has lat, lon, precipitation in mm, and observation date fields. I've been creating map services with the Javascript API and Python, but now I'm trying to figure out how to integrate SQL into the mix.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Dec 2016 14:43:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/query-layer-won-t-retain-attribute-values-when/m-p/146616#M11440</guid>
      <dc:creator>LloydBronn</dc:creator>
      <dc:date>2016-12-07T14:43:05Z</dc:date>
    </item>
    <item>
      <title>Re: Query Layer Won't Retain Attribute Values When Coverted to Table</title>
      <link>https://community.esri.com/t5/python-questions/query-layer-won-t-retain-attribute-values-when/m-p/146617#M11441</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I set up an OLE DB connection to the SQl server and set the workspace to a geodatabase. I ran the make query table tool and I got this error:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;000383 : Issue with a table; cannot find the workspace&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;IMG __jive_id="278100" alt="" class="image-1 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/278100_make_query_table.JPG" style="width: 620px; height: 569px;" /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Dec 2016 18:28:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/query-layer-won-t-retain-attribute-values-when/m-p/146617#M11441</guid>
      <dc:creator>LloydBronn</dc:creator>
      <dc:date>2016-12-07T18:28:59Z</dc:date>
    </item>
  </channel>
</rss>

