zoukankan      html  css  js  c++  java
  • sql 将英文句子中的单词首字母转换为大写

    create function dbo.pTitleCase
    (
    @StrIn nvarchar(max)
    )
    returns nvarchar(max)
    as
    begin;
    declare @StrOut nvarchar(max),
    @CurrentPosition int,
    @NextSpace int,
    @CurrentWord nvarchar(max),
    @StrLen int,
    @LastWord bit;

    set @NextSpace=1;
    set @CurrentPosition=1;
    set @StrOut='';
    set @StrLen=len(@StrIn);
    set @LastWord=0;

    while @LastWord=0
    begin;
    set @NextSpace=charindex(' ',@StrIn,@CurrentPosition+1);
    if @NextSpace=0
    begin;
    set @LastWord=1;
    set @NextSpace=@StrLen;
    end;
    set @CurrentWord=upper(substring(@StrIn,@CurrentPosition,1));
    set @CurrentWord=@CurrentWord+lower(substring(@StrIn,@CurrentPosition+1,@NextSpace-@CurrentPosition));
    set @StrOut=@StrOut+@CurrentWord;
    set @CurrentPosition=@NextSpace+1;
    end;
    return @StrOut;
    end;

  • 相关阅读:
    抽象类abstract
    final关键字特点
    继承ExtendsFour
    继承(继承中构造方法的关系)
    继承ExtendsTwo-super&this
    继承ExtendsOne
    静态
    构造方法与setXxx方法
    15.8
    15.7
  • 原文地址:https://www.cnblogs.com/mibing/p/6390710.html
Copyright © 2011-2022 走看看