如果存在(选择* from sys.objects where name='GetUpper')drop function dbo.GetUpper go CREATE function GetUpper(@words varchar(16))返回varchar(8000)as开始DECLARE @s VARCHAR(MAX)= @words--待截取字符串DECLARE @temp VARCHAR(MAX)=''--临时变量SELECT @temp=@temp+SUBSTRING(ch, sv.number, 1) FROM(SELECT @s AS ch)t CROSS APPLY [master].dbo.spt_values AS sv WHERE sv.type ='P'AND sv.number BETWEEN 1 AND LEN(ch) AND ASCII(SUBSTRING(ch, sv.number, 1)) BETWEEN ASCII('A') AND ASCII('Z') return @temp end go