SQL SPACE() function is used to return space characters, the number of the characters is indicated by the interger parameter. It is supported by MySQL and MS SQL Server, but not Oracle.

SQL SPACE Function Syntax


int: the number of the spaces.

SQL SPACE Function Example

-- Will return 9 space characters.
SELECT 'Hello' + SPACE(3) + 'World!'
-- Will return 'Hello   World!'
-- 'Hello', then 3 spaces, then 'World!'
SELECT 'Hello' + SPACE(0) + 'World!'
-- Will return 'HelloWorld!'
-- 'Hello', no space, then 'World!'

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>