I am trying to query a field in a layer but it fails converting the nvarchar value '65N' to data type int. Is there a way I can prevent it from converting and simply just run a query and print the results?
Runtime error
Traceback (most recent call last):
File "<string>", line 7, in <module>
RuntimeError: Underlying DBMS error [[Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Conversion failed when converting the nvarchar value '65N' to data type int.] [NEO_1.SDE.P_Meters]
<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
<SPAN class="keyword token">import</SPAN> arcpy
fc <SPAN class="operator token">=</SPAN> <SPAN class="string token">'Database Connections\SDE.sde\NEO_1.SDE.P_PipeSystem\NEO_1.SDE.P_Meters'</SPAN>
field <SPAN class="operator token">=</SPAN> <SPAN class="string token">'SYSTEMNUMBER'</SPAN>
cursor <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>da<SPAN class="punctuation token">.</SPAN>SearchCursor<SPAN class="punctuation token">(</SPAN>fc<SPAN class="punctuation token">,</SPAN> <SPAN class="punctuation token">(</SPAN>field<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"SYSTEMNUMBER"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">""""SYSTEMNUMBER" = 009"""</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">for</SPAN> row <SPAN class="keyword token">in</SPAN> cursor<SPAN class="punctuation token">:</SPAN>
<SPAN class="comment token"># Print the name of the different gas systems</SPAN>
<SPAN class="comment token">#</SPAN>
<SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN>row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN>
result <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>GetCount_management<SPAN class="punctuation token">(</SPAN>fc<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">'{} has {} records'</SPAN><SPAN class="punctuation token">.</SPAN>format<SPAN class="punctuation token">(</SPAN>row<SPAN class="punctuation token">,</SPAN> result<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>