<?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: String field that contains numbers not selecting specific values in ArcMap Questions</title>
    <link>https://community.esri.com/t5/arcmap-questions/string-field-that-contains-numbers-not-selecting/m-p/1031879#M2070</link>
    <description>&lt;P&gt;Yes&amp;nbsp; that should be an option, I'm using 10.8.1. Its a FC in SDE.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 02 Mar 2021 16:05:41 GMT</pubDate>
    <dc:creator>melisahansen</dc:creator>
    <dc:date>2021-03-02T16:05:41Z</dc:date>
    <item>
      <title>String field that contains numbers not selecting specific values</title>
      <link>https://community.esri.com/t5/arcmap-questions/string-field-that-contains-numbers-not-selecting/m-p/1031734#M2065</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a string field that contains both full text values, all numeric values as well as both text and numeric together. Field name = TESTNAME- Examples ( "ADAM", "500", 500-ADAM")&lt;/P&gt;&lt;P&gt;I am trying to find all numeric values in this string field with a value less than a specific value, however it does not work properly. I've tried to CAST the field to INT, but that's not working either as I get a nvarchar error. The closest I've been able to come is getting LEN(TESTNAME)&amp;lt;5 AND TESTNAME &amp;lt; 4000, However, this does not return all appropriate values. For example, the value 600 or 500 will be ignored and not returned. Any suggestions?&amp;nbsp; Thanks in advance!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Mar 2021 23:37:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcmap-questions/string-field-that-contains-numbers-not-selecting/m-p/1031734#M2065</guid>
      <dc:creator>melisahansen</dc:creator>
      <dc:date>2021-03-01T23:37:05Z</dc:date>
    </item>
    <item>
      <title>Re: String field that contains numbers not selecting specific values</title>
      <link>https://community.esri.com/t5/arcmap-questions/string-field-that-contains-numbers-not-selecting/m-p/1031770#M2066</link>
      <description>&lt;P&gt;Can you add an additional field to the table or feature?&amp;nbsp; If so, you could use field calculator to extract the number from the string using python. Then use that field for your select.&lt;/P&gt;&lt;P&gt;The following would return the number only (as a string) or an empty string for values with out a number.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;''.join(c for c in !TESTNAME! if c.isdigit())&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your same string of 'ADAM' would return an empty string of '' and 500-ADAM would return '500'.&amp;nbsp; You can also use a code block to return an integer but you need to check to see if an empty string is returned first or you will get an error.&amp;nbsp; This also assumes there is only one number per string. A sting such as '12-ADAM14' would return '1214'. Below is a code block you could use in field calculator to return a number rather than a string.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def returnNum(testname):
  tmp = ''.join(c for c in testname if c.isdigit())
  if tmp != '':
    return int(tmp)
  else:
    return 0&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This would be called with:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;returnNum( !TESTNAME!)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Mar 2021 02:55:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcmap-questions/string-field-that-contains-numbers-not-selecting/m-p/1031770#M2066</guid>
      <dc:creator>LanceCole</dc:creator>
      <dc:date>2021-03-02T02:55:09Z</dc:date>
    </item>
    <item>
      <title>Re: String field that contains numbers not selecting specific values</title>
      <link>https://community.esri.com/t5/arcmap-questions/string-field-that-contains-numbers-not-selecting/m-p/1031860#M2068</link>
      <description>&lt;P&gt;I need to be able to do this with just a select by attributes, not by creating a new field. Any ideas with that limitation?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Mar 2021 12:21:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcmap-questions/string-field-that-contains-numbers-not-selecting/m-p/1031860#M2068</guid>
      <dc:creator>melisahansen</dc:creator>
      <dc:date>2021-03-02T12:21:48Z</dc:date>
    </item>
    <item>
      <title>Re: String field that contains numbers not selecting specific values</title>
      <link>https://community.esri.com/t5/arcmap-questions/string-field-that-contains-numbers-not-selecting/m-p/1031876#M2069</link>
      <description>&lt;P&gt;I had the feeling you did not want to add additional fields.&amp;nbsp; What version of ArcGIS are you using and what level of licensing?&amp;nbsp; What is the data source, i.e. shapefile, GDB, Enterprise DB, etc.?&amp;nbsp; Select by Attribute only has a limited subset of SQL functions but there are other tools that may work or there is the option to script a select.&amp;nbsp; Are these acceptable options?&lt;/P&gt;</description>
      <pubDate>Tue, 02 Mar 2021 13:29:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcmap-questions/string-field-that-contains-numbers-not-selecting/m-p/1031876#M2069</guid>
      <dc:creator>LanceCole</dc:creator>
      <dc:date>2021-03-02T13:29:57Z</dc:date>
    </item>
    <item>
      <title>Re: String field that contains numbers not selecting specific values</title>
      <link>https://community.esri.com/t5/arcmap-questions/string-field-that-contains-numbers-not-selecting/m-p/1031879#M2070</link>
      <description>&lt;P&gt;Yes&amp;nbsp; that should be an option, I'm using 10.8.1. Its a FC in SDE.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Mar 2021 16:05:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcmap-questions/string-field-that-contains-numbers-not-selecting/m-p/1031879#M2070</guid>
      <dc:creator>melisahansen</dc:creator>
      <dc:date>2021-03-02T16:05:41Z</dc:date>
    </item>
    <item>
      <title>Re: String field that contains numbers not selecting specific values</title>
      <link>https://community.esri.com/t5/arcmap-questions/string-field-that-contains-numbers-not-selecting/m-p/1031914#M2071</link>
      <description>&lt;P&gt;When it comes to SQL support, the data source is a big factor in what can and can't be done.&amp;nbsp; As LanceCole asked, what is the data source?&lt;/P&gt;</description>
      <pubDate>Tue, 02 Mar 2021 14:38:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcmap-questions/string-field-that-contains-numbers-not-selecting/m-p/1031914#M2071</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2021-03-02T14:38:37Z</dc:date>
    </item>
    <item>
      <title>Re: String field that contains numbers not selecting specific values</title>
      <link>https://community.esri.com/t5/arcmap-questions/string-field-that-contains-numbers-not-selecting/m-p/1031966#M2072</link>
      <description>&lt;P&gt;SDE FC&lt;/P&gt;</description>
      <pubDate>Tue, 02 Mar 2021 16:06:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcmap-questions/string-field-that-contains-numbers-not-selecting/m-p/1031966#M2072</guid>
      <dc:creator>melisahansen</dc:creator>
      <dc:date>2021-03-02T16:06:16Z</dc:date>
    </item>
    <item>
      <title>Re: String field that contains numbers not selecting specific values</title>
      <link>https://community.esri.com/t5/arcmap-questions/string-field-that-contains-numbers-not-selecting/m-p/1032041#M2073</link>
      <description>&lt;P&gt;Since you are on SDE you have available a large range of SQL commands.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Try the following for the WHERE clause in your Select by Attribute.&amp;nbsp; This is not mine and is available from the blog&amp;nbsp;&lt;A href="http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/extracting-numbers-with-sql-server" target="_self"&gt;Extracting numbers with SQL Server&lt;/A&gt;. The 50 in the statement is just to limit the length of the string being processed.&amp;nbsp; If your field is larger than 50 characters, set it to the max size of the field you are checking against or you can replace it with LEN(&lt;SPAN&gt;TESTNAME). However, the statement is cumbersome&amp;nbsp;already.&amp;nbsp; Please replace "TESTNAME" in all four (4) locations with the field you are using.&amp;nbsp; The "BETWEEN 1 AND 4000" is from your example of "&amp;lt; 4000" and can be changed&amp;nbsp;to what ever you need.&amp;nbsp; Setting it to "= 0" will return records without numbers.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;(SELECT LEFT(SUBSTRING(TESTNAME, PATINDEX('%[0-9]%', TESTNAME), 50), PATINDEX('%[^0-9]%', 
SUBSTRING(TESTNAME, PATINDEX('%[0-9]%', TESTNAME), 50) + 'X') -1)) BETWEEN 1 AND 4000&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;One of the reasons it is so complex is is looks for a number anywhere in the string.&amp;nbsp; Also, It will &lt;U&gt;&lt;STRONG&gt;only&lt;/STRONG&gt;&lt;/U&gt; find the first number in a string.&amp;nbsp; "&lt;SPAN&gt;500-ADAM-600" will only be selected for 500 and not 600.&amp;nbsp; Tested on a &lt;U&gt;&lt;STRONG&gt;MS_SQL&lt;/STRONG&gt;&lt;/U&gt; SDE database using ArcGIS 10.8.1&amp;nbsp;Select by Attribute.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Mar 2021 15:30:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcmap-questions/string-field-that-contains-numbers-not-selecting/m-p/1032041#M2073</guid>
      <dc:creator>LanceCole</dc:creator>
      <dc:date>2021-03-03T15:30:45Z</dc:date>
    </item>
    <item>
      <title>Re: String field that contains numbers not selecting specific values</title>
      <link>https://community.esri.com/t5/arcmap-questions/string-field-that-contains-numbers-not-selecting/m-p/1032436#M2083</link>
      <description>&lt;P&gt;EGDBs can be deployed on a variety of DBMS, so it is good to include which one since different DBMS implement SQL support differently.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Mar 2021 15:25:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcmap-questions/string-field-that-contains-numbers-not-selecting/m-p/1032436#M2083</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2021-03-03T15:25:09Z</dc:date>
    </item>
  </channel>
</rss>

