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.
arcpy<SPAN class="punctuation token">.</SPAN>MakeQueryLayer_management<SPAN class="punctuation token">(</SPAN>DB_Conn<SPAN class="punctuation token">,</SPAN> query_layer<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"SELECT * FROM CMORPH_Test.dbo.cmorph_data WHERE precipmm > 1"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"OBJECTID"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">""</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">""</SPAN><SPAN class="punctuation token">,</SPAN> spatial_reference<SPAN class="punctuation token">)</SPAN>
desc <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>Describe<SPAN class="punctuation token">(</SPAN>query_layer<SPAN class="punctuation token">)</SPAN>
query_table <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>mapping<SPAN class="punctuation token">.</SPAN>TableView<SPAN class="punctuation token">(</SPAN>desc<SPAN class="punctuation token">.</SPAN>name<SPAN class="punctuation token">)</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>CopyRows_management<SPAN class="punctuation token">(</SPAN>query_table<SPAN class="punctuation token">,</SPAN>interim_table<SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
This creates an info table. The problem is, each one of the records 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 dbf, the date field is now zero.
Any ideas why this would happen?