December 18, 2006 at 5:13 pm
I am reading a csv file and copying the data into a sqlserver table.
At the end of successfully copying of data, I would to like to copy the csv file to a different location on the file server. How can I do the copying of the file to the new location using DTS?
thanks
nath
December 18, 2006 at 5:34 pm
Create another connection specifying where you want to copy the file to. Then, use a Transform Data task between the source connection and the new connection. The csv file will be created by DTS.
Greg
Greg
December 19, 2006 at 1:30 am
Use xp_cmdshell command in EXECUTE SQL TASK...
EXEC master..xp_cmdshell 'copy \\sourceserver\c$\test.csv \\DestnationServer\c$\test.csv
MohammedU
Microsoft SQL Server MVP
December 19, 2006 at 7:02 am
Have you also considered using an Active-X task that instanciates a "scripting.filesystemobject" and uses either the CopyFile or MoveFile methods?
There are may ways to perform this task. Determining how much control you need over this process should determine which way you should attack this problem.
Example:
dim oFSO
set oFSO=CreateObject("Scripting.FileSystemObject")
If oFSO.FileExists("c:\sourcefolder\source.csv") Then
oFSO.CopyFile "c:\sourcefolder\source.csv", "c:\destfolder\"
End If
December 19, 2006 at 7:25 am
If you are using SQL2000, the options specified by the other posters will work just fine. If you are using SQL2005 there is a copy file transform (well you can copy, move or delete files with it).
December 19, 2006 at 11:07 am
Thank You Gentle men.
I will try them.
nath
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply