让脚本每年 2 月 1 日查找一次记录
我试图考虑一种方法(我是SQL的新手),以获取此脚本,以每年2月1日每年查找一次记录。任何帮助都很棒。
select permit.PERMITID, SAVERPERMITMANAGEMENT.permitrequested, PERMITSTATUS.NAME
from PERMIT
inner join SAVERPERMITMANAGEMENT
on permit.PERMITID = SAVERPERMITMANAGEMENT.ID
inner join PERMITSTATUS
on permitstatus.PERMITSTATUSID = permit.PERMITSTATUSID
where Typeofpermitrequested = 'GUID' AND permit.PERMITSTATUSID = 'GUID'
AND PERMITTYPEID = 'GUID' AND getdate() = 2022-02-01
我被困在日期部分,以及如何使脚本每年逐年逐年查看,直到关闭为止。这是针对年度报告。
I am trying to think of a way (I am pretty new to sql) to get this script to only look for records once every year on February 1st. Any help would be awesome.
select permit.PERMITID, SAVERPERMITMANAGEMENT.permitrequested, PERMITSTATUS.NAME
from PERMIT
inner join SAVERPERMITMANAGEMENT
on permit.PERMITID = SAVERPERMITMANAGEMENT.ID
inner join PERMITSTATUS
on permitstatus.PERMITSTATUSID = permit.PERMITSTATUSID
where Typeofpermitrequested = 'GUID' AND permit.PERMITSTATUSID = 'GUID'
AND PERMITTYPEID = 'GUID' AND getdate() = 2022-02-01
I am stuck at the date portion and how to have the script look each year incrementally until turned off. This is for yearly reports.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据我对您问题的理解,您需要将查询修改为以下内容:
但是,您需要每天运行该查询&除 2 月 1 日外,您每天都会得到空结果。
因此,更好的选择是使用 SQL Server Agent:创建一个包含上述 SELECT 查询的作业安排它在每年 2 月 1 日运行。
From what I understand of your question, you would need to amend your query to the following:
However, you'd need to run that query every day & you'd get an empty result every day except February 1st.
So, a better option would be to employ something like SQL Server Agent: create a job containing the above SELECT query & schedule it to run every year on February 1st.