选择新条目以确认电子邮件 [英] Select new entries for confirmation email
问题描述
大家好,
可能有一种更简单的方式来实现我想要做的事情。如果您知道,请提出建议。
我想从三张只有一分钟的表中选择新数据。然后使用C#,发送确认和提醒电子邮件。这是我的剧本。
Hi all,
There is probably an easier way of achieving what I am trying to do. Please suggest it if you do know.
I would like to select new data from three tables that are only a minute old. Then using C#, send confirmation and reminder email. Here is my script.
SELECT B.BookingID,
S.StaffName,
A.Asset,
B.StartDate,
B.EndDate,
B.StartTime,
B.EndTime,
A.Campus,
B.Location,
B.Arrengement,
B.Messege
FROM tblBooking as B INNER JOIN tblAssets as A
on B.AssetID = A.AssetID
inner join tblStaff as S
on B.StaffID = S.StaffID
where B.StartTime <= DATE_SUB(curdate() INTERVAL 5 MINUTE)
执行上述操作时,我得到以下内容;
when executing the above, I get the following;
Msg 195, Level 15, State 10, Line 15
'curdate' is not a recognized built-in function name.
我尝试了大多数解决方案,我在网上找到了SSMS给了我不同的错误。如果你能提供帮助我很感激。
I tried most solution I found online with SSMS giving me different errors. I appreciate it if you're able help.
推荐答案
很明显......你使用的SQL版本没有一个名为<$ c $的函数C> CURDATE()。如果您使用的是SQL Server,请尝试使用getdate()
。
您可能会在DATE_SUB
上遇到类似的错误 - 尝试datediff [ ^ ]而不是。
这里的真实信息是不要在线复制解决方案,除非你确定他们是你需要的相同语言/框架/等。
It's quite clear ... whatever version of SQL you are using does not have a function calledcurdate()
. If you are using SQL Server then try usinggetdate()
.
You will probably then get a similar error onDATE_SUB
- try datediff[^] instead.
The real message here is don't copy solutions online unless you are sure they are for the same language/framework/etc that you need.
我试图用不同的函数解决它..并尝试研究。
for:
WHERE StartDate< = CONVERT(dateTime,DATEDIFF(分钟,5,GETDATE()))
我收到错误
Msg 8115,Level 16,State 2,Line 1
将表达式转换为数据类型datetime的算术溢出错误。
I have tried to resolve it using different function.. and tried researching.
for:
WHERE StartDate <= CONVERT(dateTime, DATEDIFF(minute, 5, GETDATE()))
I get error
Msg 8115, Level 16, State 2, Line 1
Arithmetic overflow error converting expression to data type datetime.
Datediff
函数返回整数 - 即。分钟数(或秒数,或年数等),不能转换为 DateTime
。使用StartDate和StartTime列以及函数中的当前日期时间,例如
The Datediff
function returns an integer - ie. the number of minutes (or seconds, or years etc etc) and cannot be converted to a DateTime
. Use your StartDate and StartTime columns and the current datetime within the function e.g.
where DATEDIFF(minute, GETDATE(), StartDate + CONVERT(DateTime, StartTime)) > 5
CURDATE
是一个mySql函数。您使用的是mySql吗?
如果您的SQL Server需要使用Getdate()
。
CURDATE
is a mySql function. Are you using mySql?
If its SQL Server you need to useGetdate()
.
这篇关于选择新条目以确认电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!