在SQL Server中将NULL转换为空字符串 [英] Convert NULL to empty string in SQL Server

查看:891
本文介绍了在SQL Server中将NULL转换为空字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I'我得到'AltReimMethod'的Null值,我想将其转换为空字符串值。查询如下:

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'

我尝试了

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

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

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

推荐答案

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

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'

这篇关于在SQL Server中将NULL转换为空字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆