使用time参数选择SQL server中where条件的查询 [英] Select query with where condition in SQL server with time parameter

查看:88
本文介绍了使用time参数选择SQL server中where条件的查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我需要通过时间从sql表中获取数据,但不要通过nano秒。但时间列包含时间(7)数据类型。







谢谢&问候

Indrajit



我尝试过:



按照传递时间从sql表中获取数据但没有传递nano秒

解决方案

做这样的事情

 选择 * 来自 #temp 
其中 timecol> = @ TimeToCheck timecol< dateadd(ss, 1 @ TimeToCheck



注意我没有使用BETWEEN,因为这相当于在右边包含等号

< = dateadd(ss,1,@ TimeToCheck)


Hi All,
I need to fetch data from sql table by pass time but without passing nano second. But time column is contain with time(7) datatype.



Thanks & Regards
Indrajit

What I have tried:

fetch data from sql table by pass time but without passing nano second

解决方案

Do something like this

select * from #temp
where timecol >= @TimeToCheck and timecol < dateadd(ss,1,@TimeToCheck)


Note I haven't used BETWEEN because that would have be the equivalent of including the equals sign on the right

<= dateadd(ss,1,@TimeToCheck)


这篇关于使用time参数选择SQL server中where条件的查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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