how to deactivate a row when it's date exceeds one month automatically ?

hi
i'm building an ASP.NET web application allows users to add an order "sell order" ,i want each order to be deactivated when it's date exceeds one or two months automatically.
- orders table must have the activated column which specifies the status of the order.
any help !!
LVL 1
RawasiAsked:
Who is Participating?
 
rajvjaCommented:
Hi

You can write a sproc and it can be scheduled to run every day.

UPDATE tablename SET Activate = 'N' where DATEDIFF(m,OrderDate,GETDATE()) >= 2
0
 
APoPhySptCommented:
Hi, perhaps you should consider using Sql Job.
By definition, Jobs : Using SQL Server Agent you can create and schedule jobs that automate routine administrative tasks. Database administrators create jobs to perform predictable administrative functions either according to a schedule or in response of events and conditions. Jobs can be simple operations containing only a single job step or can be extremely complex operations containing many job steps. SQL Server Agent is responsible for management and execution of all jobs. Agent must be running for jobs to be executed. SQL server 2k supports jobs containing operating system commands.

take a look at this link, see if it is of any help:
http://msdn.microsoft.com/en-us/library/ms191439.aspx

cheers
0
 
RawasiAuthor Commented:
thanks all
@rajvja
- do you think this scenario is the best one i can use ?
- is this solution effects the performance of the database ?
0
 
rajvjaCommented:
Hi

   I believe this is the best solution. This will not effect the performance of the database.

There are so many jobs can be scheduled like this and are meant to perform like these tasks.

Create a job and schedule to run the job every day. The job should trigger the sproc that deactivate the orders(sql query)

0
 
rajvjaCommented:
The job should be scheduled to run at offpeak time where there will be less users connected.
Generally it is at night time.
This is the scenario where most of the applications work.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.