<?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>Question Re: Format Data in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/format-data/qaa-p/13850290#M4881133</link>
    <description>&lt;P&gt;Which version of SQL Anywhere are you using?&lt;/P&gt;
&lt;P&gt;(&lt;STRONG&gt;Note:&lt;/STRONG&gt; For my answer, I am assuming you wish to break the single value '1.0 EA' in a column into two columns: '1.0' and 'EA').&lt;/P&gt;
&lt;P&gt;I'm not sure how complicated the column's string formatting can get, but if you're using version 11 or 12, you can also use the more-flexible &lt;A href="http://dcx.sybase.com/index.html#1201/en/dbreference/regexp-substr-function.html"&gt;REGEXP_SUBSTR&lt;/A&gt; SQL function to grab non-white space characters at the beginning and end of the string:&lt;/P&gt;
&lt;DIV class="codehilite"&gt;&lt;PRE&gt;&lt;SPAN class="k"&gt;create&lt;/SPAN&gt; &lt;SPAN class="k"&gt;variable&lt;/SPAN&gt; &lt;SPAN class="o"&gt;@&lt;/SPAN&gt;&lt;SPAN class="n"&gt;strval&lt;/SPAN&gt; &lt;SPAN class="nb"&gt;char&lt;/SPAN&gt;&lt;SPAN class="p"&gt;(&lt;/SPAN&gt;&lt;SPAN class="mi"&gt;10&lt;/SPAN&gt;&lt;SPAN class="p"&gt;);&lt;/SPAN&gt;  
&lt;SPAN class="k"&gt;set&lt;/SPAN&gt; &lt;SPAN class="o"&gt;@&lt;/SPAN&gt;&lt;SPAN class="n"&gt;strval&lt;/SPAN&gt; &lt;SPAN class="o"&gt;=&lt;/SPAN&gt; &lt;SPAN class="s1"&gt;'1.0 EA'&lt;/SPAN&gt;&lt;SPAN class="p"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="k"&gt;select&lt;/SPAN&gt; &lt;SPAN class="n"&gt;regexp_substr&lt;/SPAN&gt;&lt;SPAN class="p"&gt;(&lt;/SPAN&gt; &lt;SPAN class="o"&gt;@&lt;/SPAN&gt;&lt;SPAN class="n"&gt;strval&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt; &lt;SPAN class="s1"&gt;'^\\S+'&lt;/SPAN&gt; &lt;SPAN class="p"&gt;)&lt;/SPAN&gt; &lt;SPAN class="k"&gt;as&lt;/SPAN&gt; &lt;SPAN class="n"&gt;c1&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt;
   &lt;SPAN class="n"&gt;regexp_substr&lt;/SPAN&gt;&lt;SPAN class="p"&gt;(&lt;/SPAN&gt; &lt;SPAN class="o"&gt;@&lt;/SPAN&gt;&lt;SPAN class="n"&gt;strval&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt; &lt;SPAN class="s1"&gt;'\\S+$'&lt;/SPAN&gt; &lt;SPAN class="p"&gt;)&lt;/SPAN&gt; &lt;SPAN class="k"&gt;as&lt;/SPAN&gt; &lt;SPAN class="n"&gt;c2&lt;/SPAN&gt;&lt;SPAN class="p"&gt;;&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;/DIV&gt;</description>
    <pubDate>Mon, 07 Nov 2011 12:49:35 GMT</pubDate>
    <dc:creator>jeff_albion</dc:creator>
    <dc:date>2011-11-07T12:49:35Z</dc:date>
    <item>
      <title>Format Data</title>
      <link>https://community.sap.com/t5/technology-q-a/format-data/qaq-p/13850287</link>
      <description>&lt;P&gt;Not sure if this is formatting or parsing but I would like to take this bit of data: '1.00 EA'
and make it look like this: '1.00', 'EA'&lt;/P&gt;
&lt;P&gt;In other words, separate the '1.00' from the 'EA'&lt;/P&gt;
&lt;P&gt;I receive this field from a client who asks for a compare of data which requires separation of the above field.  Currently through iSQL, I build a temp table and input the clients data which gives me '1.00 EA'.  I then export that as a text file and import into excel as text, delimit the data and separate as such.&lt;BR /&gt;
&lt;/P&gt;
&lt;P&gt;Any way I could do this directly through iSQL when creating a temp table without the exporting/importing? &lt;/P&gt;
&lt;P&gt;Appreciate the help. &lt;/P&gt;</description>
      <pubDate>Mon, 07 Nov 2011 05:52:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/format-data/qaq-p/13850287</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-11-07T05:52:30Z</dc:date>
    </item>
    <item>
      <title>Re: Format Data</title>
      <link>https://community.sap.com/t5/technology-q-a/format-data/qaa-p/13850288#M4881131</link>
      <description>&lt;P&gt;I don't quite understand what it is you want to do, but if you need the two bits of the string seperated in a sql expression then this should do it:&lt;/P&gt;
&lt;DIV class="codehilite"&gt;&lt;PRE&gt;&lt;SPAN class="k"&gt;create&lt;/SPAN&gt; &lt;SPAN class="k"&gt;variable&lt;/SPAN&gt; &lt;SPAN class="n"&gt;strval&lt;/SPAN&gt; &lt;SPAN class="nb"&gt;char&lt;/SPAN&gt;&lt;SPAN class="p"&gt;(&lt;/SPAN&gt;&lt;SPAN class="mi"&gt;10&lt;/SPAN&gt;&lt;SPAN class="p"&gt;);&lt;/SPAN&gt;  
&lt;SPAN class="k"&gt;set&lt;/SPAN&gt; &lt;SPAN class="n"&gt;strval&lt;/SPAN&gt; &lt;SPAN class="o"&gt;=&lt;/SPAN&gt; &lt;SPAN class="s1"&gt;'1.0 EA'&lt;/SPAN&gt;&lt;SPAN class="p"&gt;;&lt;/SPAN&gt;  
&lt;SPAN class="k"&gt;select&lt;/SPAN&gt; &lt;SPAN class="k"&gt;left&lt;/SPAN&gt;&lt;SPAN class="p"&gt;(&lt;/SPAN&gt;&lt;SPAN class="n"&gt;strval&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt;&lt;SPAN class="n"&gt;locate&lt;/SPAN&gt;&lt;SPAN class="p"&gt;(&lt;/SPAN&gt;&lt;SPAN class="n"&gt;strval&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt;&lt;SPAN class="s1"&gt;' '&lt;/SPAN&gt;&lt;SPAN class="p"&gt;)&lt;/SPAN&gt;&lt;SPAN class="o"&gt;-&lt;/SPAN&gt;&lt;SPAN class="mi"&gt;1&lt;/SPAN&gt;&lt;SPAN class="p"&gt;)&lt;/SPAN&gt; &lt;SPAN class="k"&gt;as&lt;/SPAN&gt; &lt;SPAN class="n"&gt;Field1&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt; &lt;SPAN class="k"&gt;right&lt;/SPAN&gt;&lt;SPAN class="p"&gt;(&lt;/SPAN&gt;&lt;SPAN class="n"&gt;strval&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt;&lt;SPAN class="k"&gt;length&lt;/SPAN&gt;&lt;SPAN class="p"&gt;(&lt;/SPAN&gt;&lt;SPAN class="n"&gt;strval&lt;/SPAN&gt;&lt;SPAN class="p"&gt;)&lt;/SPAN&gt;&lt;SPAN class="o"&gt;-&lt;/SPAN&gt;&lt;SPAN class="n"&gt;locate&lt;/SPAN&gt;&lt;SPAN class="p"&gt;(&lt;/SPAN&gt;&lt;SPAN class="n"&gt;strval&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt;&lt;SPAN class="s1"&gt;' '&lt;/SPAN&gt;&lt;SPAN class="p"&gt;))&lt;/SPAN&gt; &lt;SPAN class="k"&gt;as&lt;/SPAN&gt; &lt;SPAN class="n"&gt;Field2&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;/DIV&gt;


&lt;P&gt;(The first two lines are just for this illustration of course- replace strval in the select expression with whatever the actual field name is and add a FROM clause)&lt;/P&gt;
&lt;P&gt;I'm sure one of the SQL gurus who haunt this sight will have a neater solution though &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Nov 2011 11:53:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/format-data/qaa-p/13850288#M4881131</guid>
      <dc:creator>justin_willey</dc:creator>
      <dc:date>2011-11-07T11:53:54Z</dc:date>
    </item>
    <item>
      <title>Re: Format Data</title>
      <link>https://community.sap.com/t5/technology-q-a/format-data/qaa-p/13850289#M4881132</link>
      <description>&lt;P&gt;Like Justin, I don't understand your requirements.&lt;/P&gt;
&lt;P&gt;Generally it's easiest if you get the data already with the required delimiter. Possibly you can choose a fitting delimiter when the data is exported by your customer...&lt;/P&gt;
&lt;HR /&gt;
&lt;P&gt;However, if you just want to replace a blank with another delimiter, you can also use the &lt;STRONG&gt;replace() function&lt;/STRONG&gt;, i.e. to replace the blank with a comma something like &lt;/P&gt;
&lt;DIV class="codehilite"&gt;&lt;PRE&gt;&lt;SPAN class="nb"&gt;select&lt;/SPAN&gt; &lt;SPAN class="n"&gt;replace&lt;/SPAN&gt;&lt;SPAN class="p"&gt;(&lt;/SPAN&gt;&lt;SPAN class="n"&gt;strval&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt; &lt;SPAN class="s"&gt;' '&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt; &lt;SPAN class="s"&gt;','&lt;/SPAN&gt;&lt;SPAN class="p"&gt;);&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;/DIV&gt;


&lt;P&gt;Or you could use the &lt;A href="http://dcx.sybase.com/index.html#1201/en/dbreference/sa-split-list-sysproc.html"&gt;sa_split_list() procedure&lt;/A&gt; to build a result set containing each blank-separated text as one single row:&lt;/P&gt;
&lt;DIV class="codehilite"&gt;&lt;PRE&gt;&lt;SPAN class="n"&gt;call&lt;/SPAN&gt; &lt;SPAN class="n"&gt;sa_split_list&lt;/SPAN&gt;&lt;SPAN class="p"&gt;(&lt;/SPAN&gt;&lt;SPAN class="n"&gt;strval&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt; &lt;SPAN class="s"&gt;' '&lt;/SPAN&gt;&lt;SPAN class="p"&gt;);&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;/DIV&gt;


&lt;P&gt;returns&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;line_num    row_value&lt;BR /&gt;
1           1.0&lt;BR /&gt;
2           EA&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;To recombine this, you can use the &lt;STRONG&gt;LIST aggregate&lt;/STRONG&gt;, such as&lt;/P&gt;
&lt;DIV class="codehilite"&gt;&lt;PRE&gt;&lt;SPAN class="nb"&gt;select&lt;/SPAN&gt; &lt;SPAN class="n"&gt;list&lt;/SPAN&gt;&lt;SPAN class="p"&gt;(&lt;/SPAN&gt;&lt;SPAN class="n"&gt;row_value&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt; &lt;SPAN class="s"&gt;','&lt;/SPAN&gt; &lt;SPAN class="n"&gt;order&lt;/SPAN&gt; &lt;SPAN class="n"&gt;by&lt;/SPAN&gt; &lt;SPAN class="n"&gt;line_num&lt;/SPAN&gt;&lt;SPAN class="p"&gt;)&lt;/SPAN&gt; &lt;SPAN class="n"&gt;as&lt;/SPAN&gt; &lt;SPAN class="n"&gt;MyNewRow&lt;/SPAN&gt;
&lt;SPAN class="n"&gt;from&lt;/SPAN&gt; &lt;SPAN class="n"&gt;sa_split_list&lt;/SPAN&gt;&lt;SPAN class="p"&gt;(&lt;/SPAN&gt;&lt;SPAN class="n"&gt;strval&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt; &lt;SPAN class="s"&gt;' '&lt;/SPAN&gt;&lt;SPAN class="p"&gt;);&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;/DIV&gt;


&lt;P&gt;returns&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;MyNewRow&lt;BR /&gt;
1.0,EA&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Note: Both will fail if there are blanks "inside the column data", i.e. when data like "EA" might itself contain blanks.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Nov 2011 12:32:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/format-data/qaa-p/13850289#M4881132</guid>
      <dc:creator>VolkerBarth</dc:creator>
      <dc:date>2011-11-07T12:32:57Z</dc:date>
    </item>
    <item>
      <title>Re: Format Data</title>
      <link>https://community.sap.com/t5/technology-q-a/format-data/qaa-p/13850290#M4881133</link>
      <description>&lt;P&gt;Which version of SQL Anywhere are you using?&lt;/P&gt;
&lt;P&gt;(&lt;STRONG&gt;Note:&lt;/STRONG&gt; For my answer, I am assuming you wish to break the single value '1.0 EA' in a column into two columns: '1.0' and 'EA').&lt;/P&gt;
&lt;P&gt;I'm not sure how complicated the column's string formatting can get, but if you're using version 11 or 12, you can also use the more-flexible &lt;A href="http://dcx.sybase.com/index.html#1201/en/dbreference/regexp-substr-function.html"&gt;REGEXP_SUBSTR&lt;/A&gt; SQL function to grab non-white space characters at the beginning and end of the string:&lt;/P&gt;
&lt;DIV class="codehilite"&gt;&lt;PRE&gt;&lt;SPAN class="k"&gt;create&lt;/SPAN&gt; &lt;SPAN class="k"&gt;variable&lt;/SPAN&gt; &lt;SPAN class="o"&gt;@&lt;/SPAN&gt;&lt;SPAN class="n"&gt;strval&lt;/SPAN&gt; &lt;SPAN class="nb"&gt;char&lt;/SPAN&gt;&lt;SPAN class="p"&gt;(&lt;/SPAN&gt;&lt;SPAN class="mi"&gt;10&lt;/SPAN&gt;&lt;SPAN class="p"&gt;);&lt;/SPAN&gt;  
&lt;SPAN class="k"&gt;set&lt;/SPAN&gt; &lt;SPAN class="o"&gt;@&lt;/SPAN&gt;&lt;SPAN class="n"&gt;strval&lt;/SPAN&gt; &lt;SPAN class="o"&gt;=&lt;/SPAN&gt; &lt;SPAN class="s1"&gt;'1.0 EA'&lt;/SPAN&gt;&lt;SPAN class="p"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="k"&gt;select&lt;/SPAN&gt; &lt;SPAN class="n"&gt;regexp_substr&lt;/SPAN&gt;&lt;SPAN class="p"&gt;(&lt;/SPAN&gt; &lt;SPAN class="o"&gt;@&lt;/SPAN&gt;&lt;SPAN class="n"&gt;strval&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt; &lt;SPAN class="s1"&gt;'^\\S+'&lt;/SPAN&gt; &lt;SPAN class="p"&gt;)&lt;/SPAN&gt; &lt;SPAN class="k"&gt;as&lt;/SPAN&gt; &lt;SPAN class="n"&gt;c1&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt;
   &lt;SPAN class="n"&gt;regexp_substr&lt;/SPAN&gt;&lt;SPAN class="p"&gt;(&lt;/SPAN&gt; &lt;SPAN class="o"&gt;@&lt;/SPAN&gt;&lt;SPAN class="n"&gt;strval&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt; &lt;SPAN class="s1"&gt;'\\S+$'&lt;/SPAN&gt; &lt;SPAN class="p"&gt;)&lt;/SPAN&gt; &lt;SPAN class="k"&gt;as&lt;/SPAN&gt; &lt;SPAN class="n"&gt;c2&lt;/SPAN&gt;&lt;SPAN class="p"&gt;;&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 07 Nov 2011 12:49:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/format-data/qaa-p/13850290#M4881133</guid>
      <dc:creator>jeff_albion</dc:creator>
      <dc:date>2011-11-07T12:49:35Z</dc:date>
    </item>
    <item>
      <title>Re: Format Data</title>
      <link>https://community.sap.com/t5/technology-q-a/format-data/qaa-p/13850291#M4881134</link>
      <description>&lt;P&gt;Copied the example in the documentation (link provided by Jeff) and it did the trick:&lt;/P&gt;
&lt;P&gt;Example 
The following example breaks values in the Employees.Street column into street number and street name:&lt;/P&gt;
&lt;P&gt;SELECT REGEXP_SUBSTR( Street, '^S+' ) as street_num, 
 REGEXP_SUBSTR( Street, '(?&amp;lt;=^S+s+).*$' ) AS street_name 
    FROM Employees;&lt;/P&gt;
&lt;P&gt;This is what I was looking for.  Saved one step in the process.&lt;BR /&gt;
&lt;/P&gt;
&lt;P&gt;Appreciate all the help and suggestions.&lt;BR /&gt;
&lt;/P&gt;</description>
      <pubDate>Wed, 09 Nov 2011 03:03:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/format-data/qaa-p/13850291#M4881134</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-11-09T03:03:34Z</dc:date>
    </item>
  </channel>
</rss>

