Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. SQL ToTitleCase Script

SQL ToTitleCase Script

Scheduled Pinned Locked Moved Database
tutorialdatabasecomtoolsannouncement
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jason Weibel
    wrote on last edited by
    #1

    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.

    R 1 Reply Last reply
    0
    • J Jason Weibel

      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.

      R Offline
      R Offline
      Ritesh1234
      wrote on last edited by
      #2

      Hi, U can use............... UPDATE Customer SET C_Name = LOWER(C_Name) I hope this will help u..........:-> Regards, Ritesh

      J 1 Reply Last reply
      0
      • R Ritesh1234

        Hi, U can use............... UPDATE Customer SET C_Name = LOWER(C_Name) I hope this will help u..........:-> Regards, Ritesh

        J Offline
        J Offline
        Jason Weibel
        wrote on last edited by
        #3

        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.

        R 1 Reply Last reply
        0
        • J Jason Weibel

          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.

          R Offline
          R Offline
          Ritesh1234
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups