Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Import/Export (DTS) and Replication (2000)
 DTS - Check if the file txt exist before continue

Author  Topic 

rbfigueira
Starting Member

4 Posts

Posted - 2004-01-27 : 10:41:16
Friends,

I need to do this :

I have to make one JOB that will run one DTS all days.
This DTS will import one txt file to one table in database.
Something like this:

Step 1 - Will check if the file exist. If is true (exist) the go to Step 2, else end the DTS.
Step 2 - Import the text file to the sqlserver table

The Job/DTS will never give us an error on step 1 because only verify if the file exist or not.
The step 2 only will be execute if the file exist.

How to do that ??

I need some help ;)

Thanks

Best Regards,
Ricardo
http://www.rbfigueira.net

nr
SQLTeam MVY

12543 Posts

Posted - 2004-01-27 : 10:44:49
Why use dts?
see
http://www.nigelrivett.net/ImportTextFiles.html
if you want to do it using dts
see
http://www.nigelrivett.net/DTSActivexFileExists.html

You can also use the fielexists method in a similar way.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

rbfigueira
Starting Member

4 Posts

Posted - 2004-01-27 : 10:53:00
Thanks NR !
I must to use the DTS :/

Ok, but how can i use that code ?
I will put that on Active script task ?

Can you give me the steps to do the right think....
I dont know how to put this to work :(

Sorry but i am not good on DTS manual stuff...

Best Regards,
Ricardo
http://www.rbfigueira.net
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2004-01-27 : 11:08:16
Yes use an activex script.
In it put

Function Main()
dim objFSys
dim objFStream
dim sLine
Set objFSys = CreateObject("Scripting.FileSystemObject")
if objFSys.fileexists("c:\a.txt") then
Main = DTSTaskExecResult_Success
else
Main = DTSTaskExecResult_Failure
end if
End Function

Then use the workflow to take a success or failure path.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

rbfigueira
Starting Member

4 Posts

Posted - 2004-01-27 : 11:40:48
Thanks Friend :)
Now I understand :o)

Thanks for your all help !!!

Best Regards,
Ricardo
http://www.rbfigueira.net
Go to Top of Page
   

- Advertisement -