Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 21st, 2007, 01:30 PM
Registered User
 
Join Date: Jul 2007
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default DTS ignores a 2nd ext when loading a txt file

Hi all;

I’m not sure if this was posted before but here is the issue, I have a DTS that loads a .txt file into a table, my source file connection points to the path file “c:\data_file\users.txt” and I also have an ActiveX script that checks if the file with that name is not in that folder then it stops the DTS.

What happened was I used another file with this name “users.txt.tmp” and I was expecting the DTS to stop processing as the filename doesn’t match “users.txt”, but guess what, I was surprised that it loaded the file.

So, my question is, why the DTS ignored the second extension (.tmp) as if its not there and loaded the file? Is it a bug is SQL DTS that it takes the first extension and ignores the remaining ones?

I’m kind of stuck and don’t understand why that happened.

Your thoughts are really appreciated

Thanks
Mohammad Musleh

Database Analyst/Arch
 
Old July 21st, 2007, 07:17 PM
Friend of Wrox
 
Join Date: Oct 2006
Posts: 475
Thanks: 0
Thanked 9 Times in 9 Posts
Default

What wildcards are being used in the filename's check for existance?

--Jeff Moden
 
Old July 23rd, 2007, 08:33 AM
Registered User
 
Join Date: Jul 2007
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Here is the ActiveX code I use to check for the existence of the file

Set objFSO = CreateObject("Scripting.FileSystemObject")

’’’ ImportPath = c:\data_file
’’’ ImportFile = users.txt
’’’ ImportPath and ImportFile are Global Variables

ImportPath = DTSGlobalVariables("ImportPath").Value
ImportFile = DTSGlobalVariables("ImportFile").Value

ImportFullPath = ImportPath & ImportFile

If objFSO.FileExists(ImportFullPath) Then
    Main = DTSStepScriptResult_ExecuteTask
Else
    Main = DTSStepScriptResult_DontExecuteTask
End If

Set objFSO = Nothing


Database Analyst/Arch
 
Old July 23rd, 2007, 06:10 PM
Registered User
 
Join Date: Jul 2007
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

to make things easier on you guys, here are the mains steps I have in the DTS

I have the following global variables
ImportPath, which equals to “c:\data_file” and
ImportFile, which equals to “users.txt”
FileExists, which equals to False “this is a flag I use either to move forward with the DTS or to stop it”

(1)
First thing I check in my DTS is the existence of the file that I’m loading by setting the flag “FileExists” to True or False

Function Main()
Dim objFSO, strDataFileName, ImportFullPath

Set objFSO = CreateObject("Scripting.FileSystemObject")

ImportPath = DTSGlobalVariables("ImportPath").Value
ImportFile = DTSGlobalVariables("ImportFile").Value

ImportFullPath = ImportPath & ImportFile

If objFSO.FileExists(ImportFullPath) Then
DTSGlobalVariables("FileExists").Value = True
Else
DTSGlobalVariables("FileExists").Value = False
End If

Set objFSO = Nothing
Main = DTSTaskExecResult_Success
End Function

(2)
Then I have an “Execute SQL Task” to clean up a holding table if it has data, in the workflow properties for this task, I have the following ActiveX code

Function Main()
If DTSGlobalVariables("FileExists").Value = True Then
Main = DTSStepScriptResult_ExecuteTask
Else
Main = DTSStepScriptResult_DontExecuteTask
End If
End Function

(3)
I load the file into a holding table

Then I’m done.

Thanks

Database Analyst/Arch
 
Old July 23rd, 2007, 07:16 PM
Friend of Wrox
 
Join Date: Oct 2006
Posts: 475
Thanks: 0
Thanked 9 Times in 9 Posts
Default

Um... shouldn't the following ...

ImportFullPath = ImportPath & ImportFile

... look more like ...

ImportFullPath = ImportPath & '\' & ImportFile

???

--Jeff Moden
 
Old July 24th, 2007, 01:53 PM
Registered User
 
Join Date: Jul 2007
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

you are right Jeff, I'm using "\" when I define the global variable, so my global variable ImportPath equals to “c:\data_file\”

Database Analyst/Arch





Similar Threads
Thread Thread Starter Forum Replies Last Post
TransferText Ignores Index in Import Specification nancyb Access VBA 1 September 29th, 2006 05:21 PM
Problem loading a saved DTS package afward SQL Server DTS 1 June 1st, 2006 04:30 AM
DTS - import txt , no order rows luma SQL Server DTS 2 July 14th, 2005 11:32 PM
Macro to copy data from one file to a 2nd file chadpodsednik Excel VBA 1 October 29th, 2004 10:40 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.