A trivia SQL string function SPACE()

26 03 2008

Not a really an important function, but SPACE returns a set number of spaces. For example
SELECT "HELLO" + SPACE(10) + "WORLD"
----------------------------------------------
HELLO          WORLD

I guess you can just use ” ” instead of SPACE(10), is there any specific good reason to use this function?


Actions

Information

One response

9 04 2008
P

When you don’t want to manually count the number of spacebar presses?
A value like 10 might be trivial, but let’s say you need to leave 100 spaces. Manually count 100 spacebar presses, or use SPACE(100)?

This is obviously on the assumption that there is actually a half-decent reason to put 100 spaces between words being returned from sql!

Leave a comment