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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete blank files via DTS

Status
Not open for further replies.

mitchelt

Technical User
Jul 30, 2001
21
US
Hi,

The following code works perfectly but now I want to do a little tweak at a different part of the DTS package. What I want to do is to delete files that are blank so they are not FTP'd to the remote server (a zero byte TXT file). I can see in my head what I need to do to the code, but I cannot figure it out. It seems like I would have to add some type of IF statement?

This is the code that runs after the FTP part so the files do not get sent again:

'**********************************************************************
' Visual Basic ActiveX Script
'************************************************************************

Function Main()

Dim objFSO
Dim objFolder
Dim objFile

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("C:\Websites\LocalUser\web-forms\aio\")

For Each objFile In objFolder.Files
objFile.Delete True
Next

Set objFile = Nothing
Set objFolder = Nothing
Set objFSO = Nothing

Main = DTSTaskExecResult_Success
End Function



Any help would be greatly appreciated.

Thanks!

Mitch
 
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[ut_time1]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[ut_time1]
GO
CREATE TABLE [dbo].[ut_time1] (
[data] [varchar] (255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]
GO
Try the below SQL Syntax.. Make cvhanges to your path.
[tt]
delete ut_time1
insert into ut_time1
exec master..xp_cmdshell 'type C:\text.txt'
--select * from ut_time1
if
(select count(*) from ut_time1) <>0
Begin
declare @data char(255)
set @data='del C:\text.txt'
print @data
exec master..xp_cmdshell @data
end
[/tt]


Dr.Sql
Good Luck.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top