I am going to continue my series of very short articles or tidbits on Transaction SQL string functions. I will exploring the SPACE() function today. The SPACE() function takes a positive integer replication count [C] as input. The function returns a string composed of a single space concatenated [C] times to itself as output. The example below adds one, two, and three spaces inside the title of a favorite movie of mine.
1 2 |
-- Add 1 + 2 + 3 spaces select space(1) + 'wizard' + space(2) + 'of' + space(3) + 'oz' as str_phrase |
1 2 3 4 5 |
output: str_phrase ---------------- wizard of oz |
One thing to always worry about when using TSQL functions is how will it react with…