SPACE (T-SQL)

Returns a string of repeated spaces.

Syntax

SPACE(integer_expression)

Arguments
integer_expression
Is a positive integer that indicates the number of spaces. If integer_expression is negative, a null string is returned.
Return Types

char

Remarks

To include spaces in Unicode data, use REPLICATE instead of SPACE.

Examples

This example trims the authors’ last names and concatenates a comma, two spaces, and the authors’ first names.

USE pubs

GO

SELECT RTRIM(au_lname) + ',' + SPACE(2) +  LTRIM(au_fname)

FROM authors

ORDER BY au_lname, au_fname

GO

  

Here is the result set:

Name                                                           

---------------------------------------------------------------

Bennet,  Abraham                                               

Blotchet-Halls,  Reginald                                      

Carson,  Cheryl                                                

DeFrance,  Michel                                              

del Castillo,  Innes                                           

Dull,  Ann                                                     

Green,  Marjorie                                               

Greene,  Morningstar                                           

Gringlesby,  Burt                                              

Hunter,  Sheryl                                                

Karsen,  Livia                                                 

Locksley,  Charlene                                            

MacFeather,  Stearns                                           

McBadden,  Heather                                             

O'Leary,  Michael                                              

Panteley,  Sylvia                                              

Ringer,  Albert                                                

Ringer,  Anne                                                  

Smith,  Meander                                                

Straight,  Dean                                                

Stringer,  Dirk                                                

White,  Olivier                                                

Yokomoto,  Akiko                                               

  

(23 row(s) affected)

  

See Also
String Functions  

  


(c) 1988-98 Microsoft Corporation. All Rights Reserved.