How to update data as upper case first letter with t-sql command?

前端 未结 7 710
别跟我提以往
别跟我提以往 2020-12-28 18:14

I have a table on my database. My table\'s name is \"Company\". I want to change data \"company_name\" as upper case first letter. For example;

\"ABC COMPANY\"

7条回答
  •  自闭症患者
    2020-12-28 18:40

    With a little help of a split function like this one.

    Try this, replace YourTable with whatever your table name is:

    update T
    set Name = P.Name
    from YourTable as T
      cross apply (select (select upper(left(X.s, 1))+lower(stuff(X.s, 1, 1, ''))+' '
                           from dbo.split(' ', Name) as X
                           for xml path(''), type).value('.', 'varchar(50)')
                  ) as P(Name)
    

提交回复
热议问题