views:

171

answers:

6

The site I'm working on is running Windows Server 2003 and SQL Server 8 (2000?), and ASP.NET 3.5.

I need to have some sort of script or application run to import data from an FTP'd text file, into the database. There is already a site running on the machine, that uses the current database. Can I use a scheduled task to reliably kick off some sort of .aspx page that will import the data? Or is there a better approach?

What about making sure that no one else can access the page that runs the import? I don't want random users running the import!

Thanks in advance!

P.S. some processing needs to occur on the data before its inserted. i.e. lookups, conditionals, etc, so the DB tools aren't robust enough (I think). I hate DTS, and I SSIS is not available in this version I think.

+2  A: 

Why would you use ASP.NET? Depending on the complexity of the job you could either load it directly to the database (BULK LOAD) or use DTS (SQL Server 2000) or SSIS (SQL Server 2005/2008) if more complex processing is needed.

ahockley
I hate DTS, and its way to complicated for what I need it to do.SSIS is not available (reason I supplied the version info).I need to run a script/application because there is some processing on the data that needs to occur.
SkippyFire
+1  A: 

run a BULK INSERT or bcp to import the data instead, see here http://msdn.microsoft.com/en-us/library/aa173839(SQL.80).aspx

SQLMenace
Some processing needs to occur on the data beforehand.
SkippyFire
what is this processing? Cannot be done in a SQL statement?
Sam
Maybe... but I'd rather use C# since I'm better with it. A decent amount of lookups/conversions and things need to happen, and I'm not that good with T-SQL.
SkippyFire
I'll just say this - a little SQL can save you a LOT of coding.
Sam
+4  A: 

If you want to have a C# App handle your import I would suggest a windows application (exe) w/o a form (better than a console app because it does not pop up any UI whenever it runs). Have it run every so often (every minute) by a scheduled task.

Manu
Console apps will gladly run as scheduled tasks without popping up any UI (or having a logged on user)
MNGwinn
+1  A: 

I'll echo other people here - you don't want to have a scheduled task hit a web page. SQL Server provides some good data import options, or you could just write a simple windows program and run it as a scheduled task.

Another option would be to write a windows service that watches your FTP directory and does the import.

MNGwinn
A: 

As others have said, probably a separate console application (triggered by a scheduled task) or a windows service would be the best option for this scenario.

On the other hand, if you already have all the required functionality available in the web app running on the server, then you could probably set up a scheduled task, that starts a script (VBscript, JScript), which in turn calls a page of the web app.

To have some sort of security (e.g. preventing that any user can call that page), you could add some code to the page, that checks if the page was called with http://localhost. This would at least prevent the page from being called from a remote client.

M4N
+1  A: 

DTS and stored procedures in a job.

BCP and stored procedures in a job.

You say you need to do alot of lookups and conversions? SQL is good at that - and good at doing it fast. It can seem a little intimidating at first, but it's not hard.

Sam