Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old July 13th, 2003, 02:17 PM
rjdave rjdave is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Bangalore
Posts: 1 rjdave User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via Yahoo to rjdave
Cool Xp_cmdshell

HI ,


I want to run a job schedule using sqlserver agent .
The objective is to delete files in a particular folder ,
say, "c:\myfolder" at a regular interval. The files are
video.dat or some other format files.

The entry of the
same is in a corresponding column in a table in
database,eg, Mytable.....columns
(filename,createddate,expirydate). The entry of the
filename would be deleted by the user but the physical
files (video.dat) files which are in operating system
would have to be deleted only when there is
the "expirydate" is reached . I want to use xp_cmdshell
but do not know how to write a procedure for the same to
meet my objective . Any help is a great help.

Thanks a looooooootttts in advance.

Reply With Quote
  #2  
Old August 1st, 2003, 11:37 AM
rdoekes rdoekes is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Strasbourg, France
Posts: 181 rdoekes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 20 sec
Reputation Power: 7
Send a message via AIM to rdoekes Send a message via Yahoo to rdoekes
you do not have to use a xp_cmdshell to accomplish this.

If you are a little handy with vbscript you can write a vbscript routine using the FileSystemObject, add this to a DTS package as an ActiveX Script taks and schedule the package.

This way you have a lot of control over what files and folders you would like to delete.

PHP Code:
Function Main()
Set oFSO CreateObject("scripting.FileSystemObject')
If oFSO.FolderExists("
c:MyFolder") Then
  oFSO.DeleteFolder "
c:MyFolder"
  oFSO.CreateFolder "
c:MyFolder"
End If
Set oFSO = Nothing
Main = DTSTaskExecResult_Success
End Function 

This script just deletes the folder with all content and creates a new folder with the same name.
__________________
- Rogier Doekes

Last edited by rdoekes : August 1st, 2003 at 11:53 AM.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMicrosoft SQL Server > Xp_cmdshell


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT