慕工程0101907
我玩游戏有点晚了,但是我相信这是更实用的功能,并且可以与任何语言一起使用,包括俄语,德语,泰语,越南语等。它将在'或-或之后加上大写字母。或(或)或空格(显然是:)。CREATE FUNCTION [dbo].[fnToProperCase]( @name nvarchar(500) )RETURNS nvarchar(500)ASBEGINdeclare @pos int = 1 , @pos2 intif (@name <> '')--or @name = lower(@name) collate SQL_Latin1_General_CP1_CS_AS or @name = upper(@name) collate SQL_Latin1_General_CP1_CS_AS)begin set @name = lower(rtrim(@name)) while (1 = 1) begin set @name = stuff(@name, @pos, 1, upper(substring(@name, @pos, 1))) set @pos2 = patindex('%[- ''.)(]%', substring(@name, @pos, 500)) set @pos += @pos2 if (isnull(@pos2, 0) = 0 or @pos > len(@name)) break endendreturn @nameENDGO