如何在特定时间执行存储过程 [英] How to execute Stored Procedure at specific time

查看:107
本文介绍了如何在特定时间执行存储过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我想在特定时间执行存储过程,
示例:
假设在我的网站上我有用户,并且我想阻止一个用户阻止他添加主题,
我将阻止他并将其存储在数据库中,日期时间为2011年8月12日上午,以删除该阻止.
我想在数据库中日期时间为08/12/2011 06:59:13 am时执行存储过程并删除特定用户的块

请怎么做
谢谢.

Hi every body,

I want to execute Stored Procedure at specific time,
Example:
Suppose in my website i have Users, and i want to block one User to prevent him from add topics,
i will block him and store in database datetime 08/12/2011 06:59:13 am to remove the block.
i want when the datetime 08/12/2011 06:59:13 am in database is come an stored procedure is execute and remove the block for specific user

How to do that please
Thanks.

推荐答案

http://msdn.microsoft.com/en-us/library/ms191439.aspx [ ^ ]
http://social.msdn.microsoft.com/Forums/en/sqltools/thread/40c4fd0f-53e3-4c31-a23e-64540cc55e42[^]
http://msdn.microsoft.com/en-us/library/ms191439.aspx[^]


我了解到的是您想阻止USER A添加主题.
在这里,您想使用asp.net授权来阻止用户添加主题.
对于存储过程执行,可以执行计划执行.

使用此链接
ASP.NET中的表单身份验证和授权 [ http://msdn.microsoft.com/en-us/library/system. web.security.fileauthorizationmodule.aspx [ ^ ]
What I understood is you want to block USER A from adding topics.
here u want to use asp.net authorization in order to block the user from adding Topics.
For stored procedure execution Schedule Execution is possible.

use this links
Form authentication and authorization in ASP.NET[^]


http://msdn.microsoft.com/en-us/library/system.web.security.fileauthorizationmodule.aspx[^]


我不确定我是否正确理解了该要求,但这是我的方法:

1.创建具有用户ID,要阻止的日期和时间,要取消阻止的日期和时间,被阻止状态的表( tbBlockUsers )

2.创建一个存储过程( procTimeCheck ),该存储过程获取当前时间(getdate()),并将其与 tbBlockUsers 中的阻塞和解除阻塞时间进行比较.如果找到必须被阻止或取消阻止的用户,它将调用阻止过程( procBlockUnblock ),该过程还将在 tbBlockUsers
中设置状态
3.创建一个执行 procTimeCheck 的sql代理作业,并将其安排为每秒运行一次(或您需要的粒度).
I am not sure I understand the requirement correctly, but here would be my approach:

1. create table (tbBlockUsers) with user id, date and time to block, date and time to unblock, blocked state

2. create a stored procedure (procTimeCheck) that gets the current time (getdate()) and compares it to block- and unblock time in tbBlockUsers. If it finds a user that has to be blocked or unblocked, it calls the blocking procedure (procBlockUnblock), which also sets the state in tbBlockUsers

3. create a sql agent job that executes procTimeCheck and schedule it to run every second (or whatever granularity you need).


这篇关于如何在特定时间执行存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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