views:

817

answers:

5

I've got a web server and a database server, and I'd like to run a job that uses an existing C# DLL to access the database and perform some calculations.

Is the simplest method to create a console app in C# and schedule it on the web server (app server) to run against the DB server?

I see SSIS as an option, but I don't know that well, so I thought a console app scheduled as a task would be best.

What do you think?

A: 

You don't need to write a separate console application for that if the job is very minor. you can write a page separately and write a batch file i.e. a scheduler fr the same to schedule it. You can also schedule it through window's user interface. Apart for that, if your job is plan/step of a maintenance plan (like re-indexing, taking backup of db, defragmenting , cleaning up history/log etc) then create a maintenance plan for it from you sql server, under "Management" folder available.

Samiksha
A: 

You can also call your C# DLL from a PowerShell script, and execute that script as a Scheduled Task.

For operations that require immediate actions in the background I prefer to have a service for each of my projects.

devio
A: 

You can use Quartz.NET library (quartznet.sourceforge.net) for scheduling within your console app, it is open source and it works perfectly!

Gordon Freeman
A: 

Yes the simplest solution is to create a separate console app and run it as a scheduled task.

You've got access to the web server and all the tools are already in place without having to install anything else.

ChrisF
+1  A: 

I'm a big fan of the console app + scheduled task approach. It tends to be cleaner, easier to test, and easier to re-run if something goes south. That said, if you can write the calculations in pure SQL, you could just run everything as a SQL job. Alternatively, you could take advantage of SQLCLR (.NET assemblies living within SQL Server and basically appearing as a sproc or UDF) and also run things entirely within the SQL job engine.

Wyatt Barnett
I like the SQLCLR approach because it keeps everything isolated on the database machine...
Bill Mueller
True, but the downside is the app can be difficult to test as well as many DBAs won't let you that close to their boxes.
Wyatt Barnett