SQL ToTitleCase Script
-
I need to update a field so the values change from all upper case to title case. Can anyone please point me to a sql script example of how to do this. Thanks, Jason W.
-
I need to update a field so the values change from all upper case to title case. Can anyone please point me to a sql script example of how to do this. Thanks, Jason W.
Hi, U can use............... UPDATE Customer SET C_Name = LOWER(C_Name) I hope this will help u..........:-> Regards, Ritesh
-
Hi, U can use............... UPDATE Customer SET C_Name = LOWER(C_Name) I hope this will help u..........:-> Regards, Ritesh
Thanks for the try, but that won't work. Lower gives the following results:
Select lower('TEST') ---- test
The following would work if there was only one word:Select upper(left('TEST',1)) + lower(substring('TEST', 2, len('TEST'))) ----- Test
Problem is when you have more then one word such as:DECLARE @TEST as varchar(50) SET @TEST = 'TEST TEST TEST' Select upper(left(@TEST,1)) + lower(substring(@TEST, 2, len(@TEST))) --------------------------------------------------- Test test test
The results I want are --------------------------------------------------- Test Test Test Any idea on how to output this format? Thanks again. Jason W. -
Thanks for the try, but that won't work. Lower gives the following results:
Select lower('TEST') ---- test
The following would work if there was only one word:Select upper(left('TEST',1)) + lower(substring('TEST', 2, len('TEST'))) ----- Test
Problem is when you have more then one word such as:DECLARE @TEST as varchar(50) SET @TEST = 'TEST TEST TEST' Select upper(left(@TEST,1)) + lower(substring(@TEST, 2, len(@TEST))) --------------------------------------------------- Test test test
The results I want are --------------------------------------------------- Test Test Test Any idea on how to output this format? Thanks again. Jason W.Hi, In that case u have to write ur own logic........... Here is my idea............. 1>Loop through ur string and separate our the substring till u get Space. 2>Then apply ur logic which u shown for this word and append it with @Result. 3>COntinue with ur loop till u get Next substring(word) use step 2 and append it to the @Result with Space 4>Continue till the length of Entire String...................... u might be having better logic...................:-> Regards, Ritesh