Link to home
Start Free TrialLog in
Avatar of milani_lucie
milani_lucieFlag for United States of America

asked on

Proper Case - User Defined Function is needed - SQL Server

Hi,

Can you please provide me "Proper Case" User Defined Function in SQL Server ? Here is the example i have in Java Script. Please convert this into SQL Server.


            function ConvertToProperCase()
            {
                  var inputString = document.form1.txtString.value;
                  inputString = inputString.toLowerCase();

                  var retValue = "";
                  var isFirstCharOfWord = 1;

                  for (var intCount = 0; intCount < inputString.length; intCount++)
                  {
                        var ch = inputString.charAt(intCount);

                        if (isFirstCharOfWord == 1)
                        {
                              ch = ch.toUpperCase();
                        }

                        if (ch == " ")
                        {
                              isFirstCharOfWord = 1;
                        }
                        else
                        {
                              isFirstCharOfWord = 0;
                        }

                        retValue = retValue + ch;
                  }

                  return retValue;
            }

Thanks
SOLUTION
Avatar of Lee Wadwell
Lee Wadwell
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial