Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run a C# Application periodically to update database

I would like to know whether it is possible to run a C# console or ASP.NET application periodically.

My purpose is to automatically do the following steps once a month:

1) Query a Source database.

2) Take the result of the query at (1) and manipulate them by using LINQ and C#, for instance by checking if a certain value is already present in the Destination database.

3) Store the derived data in a Destination database.

The application has to run on a Windows Server 2008, the Source database is in a SQL 2005 Server and the Destination database is in a SQL 2008 Server.

I tried to create for instance a SSIS package but it won't do the job since I cannot add any logic.

Anybody has any suggestion?

like image 564
CiccioMiami Avatar asked Jun 30 '11 14:06

CiccioMiami


3 Answers

You should create a Scheduled Task to perform this. Look here: Control Panel -> Administrative Tools -> Task scheduler

And as you stated, yes - a console app is highly recommended.


Edit

I agree with @andynormancx in that SSIS may be a better way to do this; however, it is commonly accepted to create a console app executed by a scheduled task. This is where it comes down to your resources, time, and expertise: it may or may not be worth the effort to learn enough about SSIS to create a package in SqlServer to do what you need. If someone were to give a complete answer using SSIS to perform this task, I would certainly bow to that expertise.

like image 161
IAbstract Avatar answered Oct 19 '22 23:10

IAbstract


You can create a new Scheduled Task. It would be much easier and you don't have to re-invent the wheel.

like image 41
acermate433s Avatar answered Oct 20 '22 00:10

acermate433s


You could create a scheduled task that will call your .exe at pre-defined interval.

Go to your control panel and select Scheduled Task and then add scheduled task

like image 26
Nicholas Murray Avatar answered Oct 19 '22 23:10

Nicholas Murray