Reputation: 8256
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?
Upvotes: 6
Views: 3064
Reputation: 19881
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.
Upvotes: 11
Reputation: 2544
You can create a new Scheduled Task. It would be much easier and you don't have to re-invent the wheel.
Upvotes: 4
Reputation: 5916
If you really want to do it in C# I suggest you write a service, your code is almost Identical to a normal console app.
Check the following link to get started. C# Service step by step
Upvotes: -2
Reputation: 13533
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
Upvotes: 3
Reputation: 48696
You can do it, of course. But I would recommend making it a Windows service.
Upvotes: -1