T-SQL Proper Functions
T-SQL -- Transact Server Query Language -- is the language all applications use to communicate with Microsoft's SQL Server. A T-SQL function accepts parameters, carries out an action within those parameters and returns a value as a result. The "Proper" function is one of several that works on text to change upper case and lower case.
-
Functions
-
T-SQL has multiple functions built-in for users' convenience. A function can operate on a particular value -- a set of words, characters or numbers -- and return a single value, or work on several aggregate values and deliver a total value. The language also allows users to create and define their own functions. A user-defined function can return either a single value or a table of values, and can be set up as a reusable routine.
Proper Case
-
Information stored in upper case, lower case or proper case words -- where the upper and lower case conform with normal English conventions -- is often equally valid as far as the computer's concerned. If you're making a report to a customer or writing a formal business presentation, keeping everything in proper case looks better. If you're filing records by employees' names, capitalizing the names properly is also standard practice.
-
Picking a Function
-
"Proper" and "Proper Case" are among the user-determined T-SQL functions that use text as a value and return the text in a different case. You can copy the code for one of these functions or write you're own if you're skilled in T-SQL coding. Before writing code you need to think about the end goal: Your options include capitalizing the first letter of every word, or instructing your function to make exceptions for "a" and "an."
Creating a Function
-
To create your "proper" function, identify your starting value -- the text you want to transform. The value the function returns will be the text after the capital letters are placed in the right spots. Write the parameters to allow for special conditions, such as people and place names. The function will take each character as a value, return it changed or unchanged according to the parameters, then move on and repeat with the next letter.
-