SPACE function in SQL Server
The SPACE function in SQL Server is used to return a string with the number of spaces specified in the statement.
The article will explore and show you how to use the SPACE function to create a full-space string in SQL Server.
Describe
The SPACE function in SQL Server is used to return a string with the number of spaces specified in the statement.
Syntax
To use SPACE in SQL Server, we use the following syntax:
SPACE(so_luong)
Parameters :
- so_luong: a positive integer that specifies the number of spaces. If so_luong is negative, the function returns NULL.
Note :
- SPACE can be used in later versions of SQL Server: SQL Server 2017, SQL Server 2016, SQL Server 2014, SQL Server 2012, SQL Server 2008 R2, SQL Server 2008, and SQL Server 2005.
For example
Take a look and explore some examples of SPACE functions in SQL Server.
SELECT SPACE(3);
Result: ' '
SELECT SPACE(7);
Result: ' '
SELECT SPACE(1);
Result: ' '
Previous article: RTRIM function in SQL Server
Next lesson: STR function in SQL Server
3.5 ★ | 2 Vote
You should read it
- LTRIM function in SQL Server
- How to use the function to delete spaces in Excel
- How to create space after comma in Excel
- DAY function in SQL Server
- RTRIM function in SQL Server
- MIN function in SQL Server
- MAX function in SQL Server
- The function perror () in C
- ABS function in SQL Server
- SUM function in SQL Server
- RIGHT function in SQL Server
- AVG function in SQL Server