sql - Finding Uppercase Character then Adding Space -


i bought sql world city/state database. in state database has state names pushed together. example: "northcarolina", or "southcarolina"...

is there way in sql loop , find uppercase characters , add space???

this way "northcarolina" becomes "north carolina"???

create function

if object_id('dbo.spacebeforecaps') not null     drop function dbo.spacebeforecaps go create function dbo.spacebeforecaps(@s varchar(100)) returns varchar(100) begin     declare @return varchar(100);     set @return = left(@s,1);     declare @i int;     set @i = 2;     while @i <= len(@s)     begin         if ascii(substring(@s,@i,1)) between ascii('a') , ascii('z')             set @return = @return + ' ' + substring(@s,@i,1)         else             set @return = @return + substring(@s,@i,1)         set @i = @i + 1;     end;     return @return; end; go 

then can use update database

update tbl set statename = select dbo.spacebeforecaps(statename); 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -