Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run ASP page from SQL Server

Status
Not open for further replies.

intranetgeeky

Programmer
Jun 12, 2003
17
US
I am trying to make SQL Server run an ASP page at a scheduled time each day. The ASP page is a cleanup file that removes old files from our server.

So I have two questions:
1. Can I run the ASP page from SQL Server when no one is logged into the server?

2. Is there any way to close the ASP page after a certain amount of time if I can?

Thanks.
 
If I am understanding you correctly it sounds like you have a script that you need to run everyday? Is there is a reason why you have made this an asp web page when no one is looking at it and not a batch script? That was just commentary, now on to the solution....

Whether you can execute the page with no one logged on depends on the security of your page. If you allow anonymous users and your default user has access to run everything I see no reason why that wouldn't work.

The best way to automate anything is to write a script that executes your needs. So you will need to write a batch script anyway and then in the OS of your SQL server set when it runs.

That should at least be a start in the right direction. Good luck.

Eva
 
Eva,

A batch would probably be a much better solution. I just had the ASP page all ready to go. I think I'll look into building a batch, but I have one question:

Can you delete files on the hard drive from a batch file?

I want to query records that have reached an 'expiration date' and then delete the file on the hard drive that corresponds with the record.

Any help would be greatly appreciated. Thanks.
 
actually you could use xp_cmdshell to do this within a single stored procedure that you could schedule through sql agent

in Pseudo Code

Select records from table where experiation date is <= current date

loop through the result set and execute xp_cmdshell to delete files.
exec xp_cmdshell &quot;del c:\filetodelete&quot; No_Output

This would probably require the use of a cursor so it wouldn't be the fastest or most effiecient way.

&quot;Shoot Me! Shoot Me NOW!!!&quot;
- Daffy Duck
 
Let's say I keep the current record in a variable called &quot;filetodelete&quot;. How would I call this variable from the cmdshell?

exec xp_cmdshell &quot;del c:\??filetodelete??&quot; No_Output

I can tell that we're close here... :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top