This SQL Server tutorial explains how to use the SPACE function in SQL Server (Transact-SQL) with syntax and examples.
Description
In SQL Server (Transact-SQL), the SPACE function returns a string with a specified number of spaces.
Syntax
The syntax for the SPACE functions in SQL Server (Transact-SQL) is:
SPACE( number )
Parameters or Arguments
number
The number of spaces to be returned.
Applies To
The SPACE functions can be used in the following versions of SQL Server (Transact-SQL):
- SQL Server 2017, SQL Server 2016, SQL Server 2014, SQL Server 2012, SQL Server 2008 R2, SQL Server 2008, SQL Server 2005
Example
Let’s look at some SQL Server SPACE functions examples and explore how to use the SPACE functions in SQL Server (Transact-SQL).
For example:
SELECT SPACE(3); Result: ' ' SELECT SPACE(7); Result: ' ' SELECT SPACE(1); Result: ' '