SQL SERVER – SPACE Function Example

A month ago, I wrote about SQL SERVER – TRIM() Function – UDF TRIM() . I was asked in comment if SQL Server has space function?

Yes.
SELECT SPACE(100)
will generate 100 space characters. The use of SPACE() function is demonstrated in BOL very fine.

Example from BOL:
USE AdventureWorks;
GO
SELECT RTRIM(LastName) + ',' + SPACE(2) + LTRIM(FirstName)
FROM Person.Contact
ORDER BY LastName, FirstName;
GO

Reference : Pinal Dave (https://darkslategrey-bat-805937.hostingersite.com), BOL

SQL Function, SQL Scripts
Previous Post
SQL SERVER – Restore Database Without or With Backup – Everything About Restore and Backup
Next Post
SQL SERVER – 2005 – SSMS – View/Send Query Results to Text/Grid/Files

Related Posts

Leave a Reply