I have a table Users, so some rows specially in field Full Name are in different upper/lower case, so i found this function:
我有一个表用户,所以特别是字段全名的一些行是大小写不同的,所以我找到了这个函数:
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
How can I use this function to update or select the "fullname" field from my user table?
如何使用此功能更新或从我的用户表中选择“fullname”字段?
2 个解决方案
#1
SELECT dbo.properCase(fullname) FROM [user]
and
UPDATE [user] SET fullname = dbo.properCase(fullname)
#2
SELECT dbo.properCase(FullName) FROM [User]
and:
UPDATE [User] SET FullName = dbo.properCase(FullName)
#1
SELECT dbo.properCase(fullname) FROM [user]
and
UPDATE [user] SET fullname = dbo.properCase(fullname)
#2
SELECT dbo.properCase(FullName) FROM [User]
and:
UPDATE [User] SET FullName = dbo.properCase(FullName)