admin

在SQL Server中将NULL转换为空字符串

sql

我正在获取’AltReimMethod’的Null值,我想将其转换为空字符串值。这是查询:

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

我试过了

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

并且

(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'

他们没有显示任何错误,但我什至没有任何结果。


阅读 367

收藏
2021-07-01

共1个答案

admin

在查询中应用IsNull,而不在查询中应用isull:

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