I am going to continue my series of very short articles or tidbits on Transaction SQL string functions. I will exploring the LEFT() function today. The LEFT() function takes the source string [S] and number of characters [X] as input and returns the [X] leftmost characters from string [S] as output. The following example grabs the first word from a favorite movie title of mine.
1 2 |
-- Return first word select left('wizard of oz', 6) as str_word |
1 2 3 4 5 |
output: str_word ----------- wizard |
One thing to always worry about when using TSQL functions is how will it react with empty strings, NULL values, or invalid values?…