fOcusWow
fOcusWow

Reputation: 383

Convert NULL to empty string in SQL Server

enter image description here

I'm getting Null values for 'AltReimMethod', which I want to convert to empty string values. Here's the query :

(SELECT rc.name from ReimbursementChoice rc WHERE rc.admin_id = a.admin_id AND rc.choice_id = pe.alt_payment_choice) AS 'AltReimMethod'

I tried

(SELECT (ISNULL(rc.name,' ')) from ReimbursementChoice rc WHERE rc.admin_id = a.admin_id AND rc.choice_id = pe.alt_payment_choice) AS 'AltReimMethod'

And also

(SELECT (ISNULL(CONVERT(varchar(50),rc.name),' ')) from ReimbursementChoice rc WHERE rc.admin_id = a.admin_id AND rc.choice_id = pe.alt_payment_choice) AS 'AltReimMethod'

They don't show any errors but I don't even get any results.

Upvotes: 1

Views: 7047

Answers (1)

Pranay Rana
Pranay Rana

Reputation: 176956

Apply IsNull on query, not apply isnull inside query:

ISNULL((SELECT rc.name from ReimbursementChoice rc WHERE 
rc.admin_id = a.admin_id AND rc.choice_id = pe.alt_payment_choice),' ') 
AS 'AltReimMethod'

Upvotes: 3

Related Questions