﻿<?xml version="1.0" encoding="utf-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>Manifold Community Site: SQL help please</title><link>http://95.79.92.2:8080/forum/t164865</link><description>Manifold Community Site thread</description><image><url>http://95.79.92.2:8080/forum/images/img-logo.png</url><title>Manifold Community Site: SQL help please</title><link>http://95.79.92.2:8080/forum/t164865</link></image><item><title>RE: SQL help please</title><link>http://95.79.92.2:8080/forum/t164865#164866</link><description>&lt;P&gt;I have a csv file with data that I want to join to a mesh block shp &lt;/P&gt;&lt;P&gt;The csv file has been formatted as txt for the attribute MB_2013 showing the leading 0&amp;#39;s, however it seems these leading 0&amp;#39;s are stripped when importing into Manifold 9 .&lt;/P&gt;&lt;P&gt;I have tried to add these back in using sql.&lt;/P&gt;&lt;P&gt;Here is my attempt:&lt;/P&gt;&lt;P&gt;UPDATE [2013-mb-Family]&lt;/P&gt;&lt;P&gt;SET [MB2013_a] = VALUE RIGHT(&amp;#39;0000000&amp;#39; &amp;amp; [MB2013_a], 7);&lt;/P&gt;&lt;P&gt;This returns &amp;#39;Cannot parse query&amp;#39;&lt;/P&gt;&lt;P&gt;Is there a better way to get the leading 0&amp;#39;s to show&lt;/P&gt;&lt;P&gt;Thanks in advance&lt;/P&gt;&lt;P&gt;ps, the image shows MB_2013, while the code shows MB2013_a&lt;/P&gt;&lt;P&gt;This is because I created a new attribute in my experimenting&lt;/P&gt;&lt;p class='file'&gt;&lt;b&gt;Attachments:&lt;/b&gt;&lt;br&gt;&lt;a href='bMDIvMTY0ODY2L1NjcmVlbnNob3QgMjAyNS0wNS0xNCAwNTU3MDQucG5n'&gt;&lt;img src='images/dwn-ftp.gif' align='absmiddle'&gt;&lt;/a&gt; &lt;a href='bMDIvMTY0ODY2L1NjcmVlbnNob3QgMjAyNS0wNS0xNCAwNTU3MDQucG5n'&gt;Screenshot 2025-05-14 055704.png&lt;/a&gt;&lt;br&gt;&lt;/p&gt;</description><dc:creator>Rakau</dc:creator><comments>http://95.79.92.2:8080/forum/t164865#164866</comments><guid>http://95.79.92.2:8080/forum/t164865#164866</guid><pubDate>Tue, 13 May 2025 18:24:39 GMT</pubDate></item><item><title>RE: SQL help please</title><link>http://95.79.92.2:8080/forum/t164865#164867</link><description>&lt;P&gt;How about just importing the CSV with all fields imported as text?  Use Create New Data source as described in the &lt;A HREF='https://manifold.net/doc/mfd9/index.htm#csv,_asc,_psv,_tsv,_tab.htm'&gt;&lt;B&gt;CSV topic&lt;/B&gt;&lt;/A&gt; and check the &amp;quot;Read all fields as text&amp;quot; option.&lt;/P&gt;&lt;P&gt;Don&amp;#39;t forget to &lt;A HREF='https://manifold.net/doc/mfd9/index.htm#adding_an_index_to_a_table.htm'&gt;&lt;B&gt;add an index&lt;/B&gt;&lt;/A&gt; to the resulting table.&lt;/P&gt;&lt;P&gt;You can then use the copy transform to copy text fields you want as numbers into numeric fields that you create.&lt;/P&gt;</description><dc:creator>Dimitri</dc:creator><comments>http://95.79.92.2:8080/forum/t164865#164867</comments><guid>http://95.79.92.2:8080/forum/t164865#164867</guid><pubDate>Tue, 13 May 2025 19:18:41 GMT</pubDate></item><item><title>RE: SQL help please</title><link>http://95.79.92.2:8080/forum/t164865#164868</link><description>&lt;P&gt;As long as M9 identified the column to contain integer values it will stick to it. &lt;/P&gt;&lt;P&gt;You have two solutions to overcome this :&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;in your csv add a letter before the list of 0 in the first value of the column. You import the file and it will identify the column to be nvarchar. Once imported you just remove the letter in the first value.&lt;LI&gt;you import the file as you did, add a new nvarchar column and update it using your SQL slightly modified to convert the INT to NVARCHAR using CAST&lt;/OL&gt;&lt;P class='code'&gt;&lt;span class=k&gt;UPDATE&lt;/span&gt;&amp;#160;&lt;span class=i&gt;[2013-mb-Family]&lt;/span&gt;&lt;/P&gt;&lt;P class='code'&gt;&lt;span class=k&gt;SET&lt;/span&gt;&amp;#160;&lt;span class=i&gt;[new_MB2013]&lt;/span&gt;&amp;#160;=&amp;#160;StringPadStart(&lt;span class=k&gt;CAST&lt;/span&gt;(&amp;#160;&lt;span class=i&gt;[MB2013]&lt;/span&gt;&amp;#160;&lt;span class=k&gt;AS&lt;/span&gt;&amp;#160;NVARCHAR&amp;#160;),7,&lt;span class=s&gt;&amp;#39;0&amp;#39;&lt;/span&gt;)&amp;#160;;&lt;/P&gt;&lt;P&gt;&lt;P&gt;If my understanding of the problem is correct&lt;/P&gt;&lt;/P&gt;</description><dc:creator>apo</dc:creator><comments>http://95.79.92.2:8080/forum/t164865#164868</comments><guid>http://95.79.92.2:8080/forum/t164865#164868</guid><pubDate>Wed, 14 May 2025 19:09:27 GMT</pubDate></item><item><title>RE: SQL help please</title><link>http://95.79.92.2:8080/forum/t164865#164869</link><description>&lt;P&gt;Thank you apo &amp;amp; Dimitri&lt;/P&gt;&lt;P&gt;Both helpful and aided in my learning &lt;IMG class='cons' id='i164869x0_elt' onclick="showhideImageElt('i164869x0_elt')" SRC='images/emo-smile.gif'&gt;&lt;/P&gt;</description><dc:creator>Rakau</dc:creator><comments>http://95.79.92.2:8080/forum/t164865#164869</comments><guid>http://95.79.92.2:8080/forum/t164865#164869</guid><pubDate>Wed, 14 May 2025 20:05:57 GMT</pubDate></item><item><title>RE: SQL help please</title><link>http://95.79.92.2:8080/forum/t164865#164870</link><description>&lt;BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;As long as M9 identified the column to contain integer values it will stick to it.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;No, not if you check the &amp;quot;Read all fields as text&amp;quot; option.&lt;/P&gt;</description><dc:creator>Dimitri</dc:creator><comments>http://95.79.92.2:8080/forum/t164865#164870</comments><guid>http://95.79.92.2:8080/forum/t164865#164870</guid><pubDate>Thu, 15 May 2025 04:58:47 GMT</pubDate></item><item><title>RE: SQL help please</title><link>http://95.79.92.2:8080/forum/t164865#164871</link><description>&lt;P&gt;sorry for my inaccuracy, my comment referred firstly to a direct import, not by means of a connection to the source data. Secondly, once you imported the data, the M9 SQL requires data type conversions to be explicit, and this is where I used the term stick to type.&lt;/P&gt;&lt;P&gt;In the case you need M9 to import part of the columns as int or float and part of text, the first trick is the more effective one, but everyone can choose its way. &lt;/P&gt;&lt;P&gt;The best would be a complete connector allowing to set all the columns types...&lt;/P&gt;</description><dc:creator>apo</dc:creator><comments>http://95.79.92.2:8080/forum/t164865#164871</comments><guid>http://95.79.92.2:8080/forum/t164865#164871</guid><pubDate>Thu, 15 May 2025 05:14:32 GMT</pubDate></item><item><title>RE: SQL help please</title><link>http://95.79.92.2:8080/forum/t164865#164876</link><description>&lt;P&gt;Or, CSV format could be used correctly by the author of the data.  The CSV convention is that fields which are intended to be imported as text are delimited by double quote &amp;quot; characters.  If double quotes are used (or any other character used as a text qualifier when using create new data source) the column will be imported as nvarchar text.&lt;/P&gt;&lt;P&gt;You can also do the first trick by enclosing the first value of the desired column with double quote &amp;quot; characters. The automatic type deducer will take that to indicate the column should be type nvarchar.  That works both with the current 181.0 build as well as the upcoming 181.1 build which changes the CSV dataport to be RFC 4180 compliant.&lt;/P&gt;&lt;P&gt;By the way, using File - Create - New Data Source, as discussed in the CSV topic doesn&amp;#39;t mean you have to leave the data in the original source file.  The point of using New Data Source is to utilize the greater set of options available to you to connect to the CSV.  It takes but a moment then to copy the table created and paste it into the local part of your project, just like an import.&lt;/P&gt;&lt;P&gt;The OP mentions &amp;quot;The csv file has been formatted as txt&amp;quot; - it would be interesting to see the original file (or a representative first few dozen lines of it) to see if that field was indeed &amp;quot;formatted as txt&amp;quot; by using some delimiting character.  In that case, there&amp;#39;s no need for any workarounds, just a need to use the right import method in Manifold.&lt;/P&gt;</description><dc:creator>Dimitri</dc:creator><comments>http://95.79.92.2:8080/forum/t164865#164876</comments><guid>http://95.79.92.2:8080/forum/t164865#164876</guid><pubDate>Thu, 15 May 2025 09:26:53 GMT</pubDate></item><item><title>RE: SQL help please</title><link>http://95.79.92.2:8080/forum/t164865#164879</link><description>&lt;P&gt;I fully agree with all those statements, but regarding the first one :&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;GIS users are not always the author of the data &lt;/UL&gt;&lt;P&gt;&lt;LI&gt;Data producers are not always (should I say rarely) aware of what correct is&lt;P&gt;Mixing both as a standard reality, you have better to know all the tricks you have to overcome the problem. This is what I find interesting in M9, having lot of flexibility.&lt;/P&gt;&lt;/P&gt;</description><dc:creator>apo</dc:creator><comments>http://95.79.92.2:8080/forum/t164865#164879</comments><guid>http://95.79.92.2:8080/forum/t164865#164879</guid><pubDate>Thu, 15 May 2025 09:48:00 GMT</pubDate></item></channel></rss>