DECLARE
或
SELECT top 1 'Uploaded_Date' =
CASE isnull(Uploaded_Date,'')
WHEN Uploaded_Date THEN 'NOT UPDATED'
else uploaded_date
END
FROM ABC
当Uploaded_date列为null或为空时,它应该返回NOT UPDATED,而是返回NULL ..!
先谢谢
答案 0 :(得分:0)
尝试使用以下查询。
SELECT top 1
CASE WHEN (Uploaded_Date IS NULL or LTRIM (RTRIM (isnull(Uploaded_Date,'')))='NULL')
THEN CAST('NOT UPDATED' AS VARCHAR(50))
ELSE CAST(uploaded_date AS VARCHAR(50)) END as 'Uploaded_Date'
FROM ABC
答案 1 :(得分:0)
您正尝试将int
值设置为Uploaded_Date
varchar(50)
。而不是存储int
0
存储'0'
,即varchar并在case
语句中进行比较。它应该可以工作。
SELECT top 1 'Uploaded_Date' =
CASE isnull(Uploaded_Date,'0')
WHEN '0' THEN 'NOT UPDATED'
else uploaded_date
END
FROM ABC