如何基于T-SQL中的适当大小写将“ ThisIsTest”之类的字符串转换为“ This Is Test”?
答案 0 :(得分:1)
尝试一下。
DECLARE @Input VARCHAR(MAX)='ColumnA'
DECLARE @Regex AS VArCHAR(MAX), @Output AS VARCHAR(MAX)
SET @Output = @Input
SET @Regex = '%[^ ][A-Z]%'
WHILE PATINDEX(@Regex collate Latin1_General_Bin, @Output) > 0
BEGIN
SET @Output = Stuff(@Output, PatIndex(@Regex collate Latin1_General_Bin, @Output) + 1, 0, ' ')
END
SELECT @Output AS [Output]