Heathenry
Heathenry

Reputation: 21

SQL - completing with spaces if NULL?

Currently trying to write a query, and wanting to complete a field with spaces if it is NULL.

For example:

SELECT * FROM (X)
WHERE YEAR = @TaxYear              
LEN(SortCode) > 6 and ISNUMERIC(SUBSTRING(SortCode,1,6)) = 1

Upvotes: 0

Views: 43

Answers (1)

paul
paul

Reputation: 22001

To replace a null value with six spaces use COALESCE(columnName, ' ')

Upvotes: 1

Related Questions