Visual Studio 2013中的SQL查询问题 [英] Problem with SQL query in visual studio 2013

查看:97
本文介绍了Visual Studio 2013中的SQL查询问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SELECT COUNT(id)
FROM tableA
WHERE DATE(getdate) = '2016-08-14'





getdate数据类型是datetime但是现在我只想要约会。



我得到的错误是



错误WHERE子句附近'('。

WHERE子句中的错误''。

无法解析查询文本。



我尝试了什么:



我尝试过使用所有解决方案,但仍然无法使用

http://stackoverflow.com/questions/6119369/simple-datetime-sql-query [ ^ ]

推荐答案

如果你看这个链接 http://www.w3schools.com/sql/sql_dates.asp [ ^ ],您会看到您的日期字符串格式错误。

尝试:2016-10-08



帮助您学习SQL的网站: http://www.w3schools.com/sql /default.asp [ ^ ]



[更新]

您应该正确学习SQL!

getdate GETDATE()不是一回事!

http://www.codeproject.com/script/Answers/Post.aspx?aid=1137143 [ ^ ]
If you look at this link http://www.w3schools.com/sql/sql_dates.asp[^] , you will see that your date as a string is in wrong format.
try: 2016-10-08

Site to help you to learn SQL: http://www.w3schools.com/sql/default.asp[^]

[Update]
You should learn SQL properly !
getdate and GETDATE() are not the same thing !
http://www.codeproject.com/script/Answers/Post.aspx?aid=1137143[^]


假设Microsoft SQL Server,请尝试以下方法:

Assuming Microsoft SQL Server, try something like this:
DECLARE @TheDate date = '20160814';

SELECT COUNT(id)
FROM tableA
WHERE getdate >= @TheDate
AND getdate < DateAdd(day, 1, @TheDate);


这篇关于Visual Studio 2013中的SQL查询问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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