I am trying to apply the IsNull
function to a column of a datatype date
. What am trying to do is, to replace the word NULL
with an empty string (actual null value) when retrieving the data
我试图将IsNull函数应用于数据类型日期的列。我想要做的是,在检索数据时用空字符串(实际空值)替换单词NULL
The code am using is;
我正在使用的代码是;
Select
ISNULL("UPDATE_DT", '')
from
MyTable
I have also tried
我也试过了
Select
ISNULL("UPDATE_DT", 0)
from
MyTable
The error am getting is
我得到的错误是
Msg 103010, Level 16, State 1, Line 1
Parse error at line: 4, column: 1: Incorrect syntax near 'from'.消息103010,级别16,状态1,行1行中的解析错误:4,列:1:'from'附近的语法不正确。
1 个解决方案
#1
4
If you want to see the column as an empty string rather than "NULL", you need to convert the output to a string. To control the format, use convert()
:
如果要将列视为空字符串而不是“NULL”,则需要将输出转换为字符串。要控制格式,请使用convert():
select coalesce(convert(varchar(10), update_dt, 121), '')
. . .
Then use coalesce()
(or if you must, isnull()
) to replace the NULL
value with another string.
然后使用coalesce()(或者如果必须,isnull())将NULL值替换为另一个字符串。
#1
4
If you want to see the column as an empty string rather than "NULL", you need to convert the output to a string. To control the format, use convert()
:
如果要将列视为空字符串而不是“NULL”,则需要将输出转换为字符串。要控制格式,请使用convert():
select coalesce(convert(varchar(10), update_dt, 121), '')
. . .
Then use coalesce()
(or if you must, isnull()
) to replace the NULL
value with another string.
然后使用coalesce()(或者如果必须,isnull())将NULL值替换为另一个字符串。