Convert NULL to empty string in SQL Server

2019-07-31 00:55发布

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.

1条回答
疯言疯语
2楼-- · 2019-07-31 01:26

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'
查看更多
登录 后发表回答