如何在T-SQL中根据适当的大小写将字符串从'ThisIsTest'转换为'This Is Test'?
- 输入:'ColumnA'
- 输出:'Column A'
如何在T-SQL中根据适当的大小写将字符串从'ThisIsTest'转换为'This Is Test'?
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]
REPLACE()
函数...不过我不确定。如果是这种情况,那似乎相当令人沮丧。 - ZLK