How can I copy a file (csv) to a different location?

  • 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

     

     

  • 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

  • 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

  • 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

  • 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).

  • 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