tags:

views:

67

answers:

2

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?

+2  A: 
SELECT dbo.properCase(FullName) FROM [User]

and:

UPDATE [User] SET FullName = dbo.properCase(FullName)
Sean Bright
+2  A: 
SELECT dbo.properCase(fullname) FROM [user]

and

UPDATE [user] SET fullname = dbo.properCase(fullname)
CodeMonkey1