<?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: Using SQL CAST functionality in against a File Geodatabase in Data Management Questions</title>
    <link>https://community.esri.com/t5/data-management-questions/using-sql-cast-functionality-in-against-a-file/m-p/209581#M12017</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migrated-users/12477"&gt;Doug Browning&lt;/A&gt;‌, I am confused by this last comment.&amp;nbsp; Are you working with in-memory geodatabases again and CAST isn't working?&amp;nbsp; Or, are you working with file geodatabases and CAST isn't working?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 08 Jul 2019 21:50:44 GMT</pubDate>
    <dc:creator>JoshuaBixby</dc:creator>
    <dc:date>2019-07-08T21:50:44Z</dc:date>
    <item>
      <title>Using SQL CAST functionality in against a File Geodatabase</title>
      <link>https://community.esri.com/t5/data-management-questions/using-sql-cast-functionality-in-against-a-file/m-p/209575#M12011</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;There are a number of references in ESRI's documentation&amp;nbsp; (&lt;/SPAN&gt;&lt;A href="http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?TopicName=SQL_reference"&gt;http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?TopicName=SQL_reference&lt;/A&gt;&lt;SPAN&gt;) and other threads (&lt;/SPAN&gt;&lt;A href="http://forums.esri.com/Thread.asp?c=159&amp;amp;f=1707&amp;amp;t=280410"&gt;http://forums.esri.com/Thread.asp?c=159&amp;amp;f=1707&amp;amp;t=280410&lt;/A&gt;&lt;SPAN&gt;) that seem to indicate that one can use the SQL "CAST" function in a where statement against a file geodatabase to convert field types on the fly.&amp;nbsp; I'm trying to pull records based on a set of integers that begin with a particular number.&amp;nbsp; To do so, I should cast the integer field to a character, and then perform a LIKE statement against the field.&amp;nbsp; By all rights, and per documentation, the following statement should work against a File GDB: &lt;/SPAN&gt;&lt;SPAN style="font-family:Courier New;"&gt;CAST("Price" AS CHARACTER) LIKE '1%'&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; But... it does not.&amp;nbsp; It doesn't work in ArcMap 10, and it doesn't work in 9.3&amp;nbsp; What am I doing wrong here?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Apr 2012 15:53:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/using-sql-cast-functionality-in-against-a-file/m-p/209575#M12011</guid>
      <dc:creator>DominickCisson</dc:creator>
      <dc:date>2012-04-19T15:53:32Z</dc:date>
    </item>
    <item>
      <title>Re: Using SQL CAST functionality in against a File Geodatabase</title>
      <link>https://community.esri.com/t5/data-management-questions/using-sql-cast-functionality-in-against-a-file/m-p/209576#M12012</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Use:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;CAST("Price" AS CHARACTER(12)) LIKE '1%'&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I need to add this to the doc. The width of the character field must be set. It's consistent with other SQL implementations, but it's not obvious.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Apr 2012 16:19:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/using-sql-cast-functionality-in-against-a-file/m-p/209576#M12012</guid>
      <dc:creator>LanceShipman</dc:creator>
      <dc:date>2012-04-19T16:19:54Z</dc:date>
    </item>
    <item>
      <title>Re: Using SQL CAST functionality in against a File Geodatabase</title>
      <link>https://community.esri.com/t5/data-management-questions/using-sql-cast-functionality-in-against-a-file/m-p/209577#M12013</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Use:&lt;BR /&gt;CAST("Price" AS CHARACTER(12)) LIKE '1%'&lt;BR /&gt;&lt;BR /&gt;I need to add this to the doc. The width of the character field must be set. It's consistent with other SQL implementations, but it's not obvious.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hallelujah!&amp;nbsp; I tried every combination I could think of, including "varchar" with a width, but I never put a width on "character".&amp;nbsp; It's always fun navigating the vagaries of SQL across SQL Server, File GDB's and Personal GDB's&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 19 Apr 2012 16:49:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/using-sql-cast-functionality-in-against-a-file/m-p/209577#M12013</guid>
      <dc:creator>DominickCisson</dc:creator>
      <dc:date>2012-04-19T16:49:28Z</dc:date>
    </item>
    <item>
      <title>Re: Using SQL CAST functionality in against a File Geodatabase</title>
      <link>https://community.esri.com/t5/data-management-questions/using-sql-cast-functionality-in-against-a-file/m-p/209578#M12014</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What about for DOUBLE or INT?&amp;nbsp; I can never get cast to work for numbers and had given up till I saw this post.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CAST(RockFragments AS DOUBLE)&amp;nbsp; is a no go&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Jul 2019 19:56:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/using-sql-cast-functionality-in-against-a-file/m-p/209578#M12014</guid>
      <dc:creator>DougBrowning</dc:creator>
      <dc:date>2019-07-03T19:56:08Z</dc:date>
    </item>
    <item>
      <title>Re: Using SQL CAST functionality in against a File Geodatabase</title>
      <link>https://community.esri.com/t5/data-management-questions/using-sql-cast-functionality-in-against-a-file/m-p/209579#M12015</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok finally got it.&amp;nbsp; You need to use NUMERIC and give it a size.&amp;nbsp; You also need the field name in "".&lt;/P&gt;&lt;P&gt;So this worked&lt;/P&gt;&lt;P&gt;CAST("RockFragments" AS NUMERIC(38,9)) &amp;lt;&amp;gt; (CAST("ESD_FragVolPct" AS NUMERIC(38,9)) + CAST("ESD_FragVolPct2" AS NUMERIC(38,9)) + CAST("ESD_FragVolPct3" AS NUMERIC(38,9)))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This help says you can use double but it never works.&amp;nbsp; Crazy how bad this help page is.&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="http://desktop.arcgis.com/en/arcmap/10.3/map/working-with-layers/sql-reference-for-query-expressions-used-in-arcgis.htm" title="http://desktop.arcgis.com/en/arcmap/10.3/map/working-with-layers/sql-reference-for-query-expressions-used-in-arcgis.htm"&gt;SQL reference for query expressions used in ArcGIS—Help | ArcGIS for Desktop&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edit:&amp;nbsp;&lt;/P&gt;&lt;P&gt;This worked great in a ArcMap Def Query but bombed in a search cursor in python with invalid SQL statement.&lt;/P&gt;&lt;P&gt;whereClause = 'CAST("RockFragments" AS NUMERIC(38,9)) &amp;lt;&amp;gt; (CAST("ESD_FragVolPct" AS NUMERIC(38,9)) + CAST("ESD_FragVolPct2" AS NUMERIC(38,9)) + CAST("ESD_FragVolPct3" AS NUMERIC(38,9)))'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is hitting a in_memory table so that may be it.&amp;nbsp; I have found that in_memory sets do not support all the SQL that geoDBs do.&amp;nbsp; Which is not documented or anything.&amp;nbsp; This may be what stopped me from cast in the past.&amp;nbsp; Bummer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any ideas?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Jul 2019 20:11:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/using-sql-cast-functionality-in-against-a-file/m-p/209579#M12015</guid>
      <dc:creator>DougBrowning</dc:creator>
      <dc:date>2019-07-03T20:11:27Z</dc:date>
    </item>
    <item>
      <title>Re: Using SQL CAST functionality in against a File Geodatabase</title>
      <link>https://community.esri.com/t5/data-management-questions/using-sql-cast-functionality-in-against-a-file/m-p/209580#M12016</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yep found my own old post about it. I was hoping it was the numeric issue.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/thread/218020-cast-does-not-work-in-searchcursor-queries"&gt;https://community.esri.com/thread/218020-cast-does-not-work-in-searchcursor-queries&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Jul 2019 21:36:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/using-sql-cast-functionality-in-against-a-file/m-p/209580#M12016</guid>
      <dc:creator>DougBrowning</dc:creator>
      <dc:date>2019-07-03T21:36:57Z</dc:date>
    </item>
    <item>
      <title>Re: Using SQL CAST functionality in against a File Geodatabase</title>
      <link>https://community.esri.com/t5/data-management-questions/using-sql-cast-functionality-in-against-a-file/m-p/209581#M12017</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migrated-users/12477"&gt;Doug Browning&lt;/A&gt;‌, I am confused by this last comment.&amp;nbsp; Are you working with in-memory geodatabases again and CAST isn't working?&amp;nbsp; Or, are you working with file geodatabases and CAST isn't working?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Jul 2019 21:50:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/using-sql-cast-functionality-in-against-a-file/m-p/209581#M12017</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2019-07-08T21:50:44Z</dc:date>
    </item>
    <item>
      <title>Re: Using SQL CAST functionality in against a File Geodatabase</title>
      <link>https://community.esri.com/t5/data-management-questions/using-sql-cast-functionality-in-against-a-file/m-p/209582#M12018</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It works in a GDB but does not work when hitting a in_memory set in Python.&amp;nbsp; Says invalid SQL statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Jul 2019 22:15:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/using-sql-cast-functionality-in-against-a-file/m-p/209582#M12018</guid>
      <dc:creator>DougBrowning</dc:creator>
      <dc:date>2019-07-08T22:15:12Z</dc:date>
    </item>
    <item>
      <title>Re: Using SQL CAST functionality in against a File Geodatabase</title>
      <link>https://community.esri.com/t5/data-management-questions/using-sql-cast-functionality-in-against-a-file/m-p/209583#M12019</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ah, OK, now I get what you are saying.&amp;nbsp; Yes, in-memory workspaces in ArcMap do not support all the SQL statements that file geodatabases support.&amp;nbsp; I have not experimented yet with the new "memory" workspace in Pro, but I suspect it will also have even more limited SQL support.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;UPDATE:&amp;nbsp; &lt;A href="https://community.esri.com/migrated-users/12477"&gt;Doug Browning&lt;/A&gt;‌, good news, I just checked Pro and the new "memory" workspace works with SQL CAST while the older "in_memory" workspace does not.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Jul 2019 15:22:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/using-sql-cast-functionality-in-against-a-file/m-p/209583#M12019</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2019-07-09T15:22:20Z</dc:date>
    </item>
    <item>
      <title>Re: Using SQL CAST functionality in against a File Geodatabase</title>
      <link>https://community.esri.com/t5/data-management-questions/using-sql-cast-functionality-in-against-a-file/m-p/209584#M12020</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok I have a new one today that I cannot find any info on.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Using a GDB.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to a Definition Query for tab \t.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This&amp;nbsp; (also tried CHAR)&lt;/P&gt;&lt;P&gt;SpeciesWoody LIKE '%' || CHR(9) || '%'&lt;/P&gt;&lt;P&gt;or this should work but it is not&lt;/P&gt;&lt;P&gt;SpeciesWoody LIKE '%' + CHR(9) + '%'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also tried looking for a \ using&lt;/P&gt;&lt;P&gt;'%\\%'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyone have any ideas?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Mar 2020 19:37:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/using-sql-cast-functionality-in-against-a-file/m-p/209584#M12020</guid>
      <dc:creator>DougBrowning</dc:creator>
      <dc:date>2020-03-31T19:37:37Z</dc:date>
    </item>
    <item>
      <title>Re: Using SQL CAST functionality in against a File Geodatabase</title>
      <link>https://community.esri.com/t5/data-management-questions/using-sql-cast-functionality-in-against-a-file/m-p/209585#M12021</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You will need to build and apply the definition query outside of the GUI, e.g., ArcPy layer.definitionQuery.&amp;nbsp; The following worked for me when testing:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;tbl.definitionQuery = "SpeciesWoody LIKE '%" + chr(9) + "%'"&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 Mar 2020 20:37:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/using-sql-cast-functionality-in-against-a-file/m-p/209585#M12021</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2020-03-31T20:37:21Z</dc:date>
    </item>
  </channel>
</rss>

