Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Try this procedure ...</p> <pre><code>create procedure updateName() begin declare cnt, len, val, flag int; declare newName, oldName varchar(30); select count(*) into cnt from tbl; set cnt =cnt-1; while cnt &gt;= 0 do set flag=0; select details into oldName from tbl limit cnt, 1; select length(oldname) into len; while flag=0 and len &gt; 0 do select ascii(substring(oldname, len)) into val; if val &lt; 90 then select concat(substring(oldname, 1, len-1), ' ', substring(oldname,len)) into newname; update tbl set details = newName where details = oldname; set flag=1; end if; set len = len - 1; end while; set cnt = cnt-1; end while; end// </code></pre> <h2><strong><a href="http://sqlfiddle.com/#!2/19929/1" rel="nofollow">FIDDLE</a></strong></h2> <h2><em><strong>EDIT</em></strong></h2> <p>For multiple caps char To solve the prob of multiple caps char</p> <pre><code>create procedure updateName() begin declare cnt, len, val, flag int; declare newName, oldName varchar(30); select count(*) into cnt from tbl; set cnt =cnt-1; while cnt &gt;= 0 do set flag=0; select details into oldName from tbl limit cnt, 1; select length(oldname) into len; while len &gt; 1 do select ascii(substring(oldname, len)) into val; if val &lt; 90 then select concat(substring(oldname, 1, len-1), ' ', substring(oldname,len)) into newname; update tbl set details = newName where details = oldname; set oldname=newname; end if; set len = len - 1; end while; set cnt = cnt-1; end while; end// </code></pre> <h2><strong><a href="http://sqlfiddle.com/#!2/ceee3/1" rel="nofollow">FIDDLE</a></strong></h2> <p>Take a back up of your table before running this proc..</p> <p>Hope this helps....</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload