SQL Server时间检索怀疑 [英] Sql Server Time Retrieving Doubt

查看:92
本文介绍了SQL Server时间检索怀疑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从数据库中检索TIME,我这样做的方式是


select CONVERT(varchar,time,100) as TIME from table

我的问题是,如果上述查询的结果为空,那么我想显示一个字符串,例如没有值"


我使用了CASE WHEN语法,但显示错误



任何帮助都将是gratefull

I am retrieving TIME from database,the way i did is


select CONVERT(varchar,time,100) as TIME from table

my question is,if the result of above query is null,then i want to display a string like ''There is no Value''


I used CASE WHEN syntax,but its showing errors



Any help will be gratefull

推荐答案

使用COALESCE.并将默认文本作为第二个参数传递.

请参见 http://msdn.microsoft.com/en-us/library/ms190349.aspx [ ^ ]
Use COALESCE. And pass the default text as the 2nd argument.

See http://msdn.microsoft.com/en-us/library/ms190349.aspx[^]


您可以执行类似
的操作
You could do something like

Select TIME =
    CASE WHEN time = NULL THEN 'There is no Value'
    ELSE CONVERT(varchar,time,100)
    END
 from table


这篇关于SQL Server时间检索怀疑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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