SQL Flow Field Guide

SPACE

Catalog support for SQL Server 2022 (16.x) and 2025 (17.x)

string transform

What changes

Input
string arguments
Output or change
string or integer
Return type
varchar

Syntax at a glance

SPACE ( integer_expression )

Work example

Create a string with a requested count of spaces for output formatting.

Test Unicode, trailing spaces, collation, empty input, and maximum output length.

Check your work Bound the count and keep presentation padding out of stored business values.

Open Microsoft Learn for full syntax, permissions, and details for your version.