我有一个表用户,所以一些专门在字段全名中的行是大小写不同的,所以我找到了这个函数:
CREATE function properCase(@texto varchar(8000)) returns varchar(8000) as
begin
--declare @texto = 'hola'
set @texto = lower(@texto)
declare @i int
set @i = ascii('a')
while @i <= ascii('z')
begin
set @texto = replace(@texto, ' ' + char(@i), ' ' + char(@i-32))
set @i = @i + 1
end
set @texto = char(ascii(left(@texto, 1))-32) + right(@texto, len(@texto)-1)
return @texto
end
如何使用此功能更新或从我的用户表中选择“fullname”字段?
答案 0 :(得分:2)
SELECT dbo.properCase(FullName) FROM [User]
和
UPDATE [User] SET FullName = dbo.properCase(FullName)
答案 1 :(得分:2)
SELECT dbo.properCase(fullname) FROM [user]
和
UPDATE [user] SET fullname = dbo.properCase(fullname)