Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
Posted
Updated 9-Nov-11 19:30pm
v3
Comments
sandesh.mumbai 10-Nov-11 1:18am    
will you please explain what exactly u r doing?
From where u want to execute SP?
MrLonely_2 10-Nov-11 1:31am    
I updated my question to be more clear,
thanks.

 
Share this answer
 
Comments
MrLonely_2 10-Nov-11 1:32am    
I do not want to make schedule stored procedure,
I want to run it at specific time for one time only
thanks.
Prerak Patel 10-Nov-11 3:14am    
Check step 6 in second link.
Click One time if you want the schedule to run only once. To set the One time schedule, complete the One-time occurrence group on the dialog.
MrLonely_2 10-Nov-11 3:33am    
Thanks, but there are two points:
1- how to bind the Job with my Stored Procedure?
2- I want to set the the time that Job will occur in it, at run time by another Stored Procedure.
I hope you understand me...
sandesh.mumbai 10-Nov-11 5:14am    
u can also use Triggers in sql database.
In programming u can use timers & threading for performing same.
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[^]
 
Share this answer
 
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).
 
Share this answer
 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900