hi i want to copy a zip mfile from one location to other after renaming it in DTS Packages using VB Script

  • hi i want to copy a zip mfile from one location to other after renaming it in DTS Packages using VB Script.

  • You can use tsql instead VB script use rename and copy the file...

    exec xp_cmdshell 'rename \\servername\c$\filename.zip filename_new.zip'

    exec xp_cmdshell 'copy \\servername\c$\filename_new.zip \\servername\d$\filename_new.zip'

    If you want to use in DTS execute the above code in EXECUTE SQL task...

     

    MohammedU
    Microsoft SQL Server MVP

  • Alternatively you could use a scripting task and the FSO to avoid using xp_cmdshell

     

    Dim oFSO

     

                Dim sDestinationFile

                Dim sDestinationPath

                Dim sSourceFile

                Dim sSourcePath

               

    sSourcePath =  "YourSourcePath"

     

                sSourceFile = sSourcePath & "YourZip.zip"

     

                sDestinationPath = "YourDestinationPath"

     

                sDestinationFile = sDestinationPath & "YourNewName.zip"

     

                Set oFSO = CreateObject("Scripting.FileSystemObject")

     

                If oFSO.FileExists(sDestinationFile) Then

                            oFSO.DeleteFile sDestinationFile

                End If

     

                oFSO.MoveFile sSourceFile, sDestinationFile

     

                Main = DTSTaskExecResult_Success

    -------------------------------------------------------------------------
    Normal chaos will be resumed as soon as possible. :crazy:

  • hi john,

     

    thanks ,

    just let me know do i have to declare anything else in the script to get access.

     

    i am not able to run it ....

    its giving me the error...

     

    as i am new to this sql server i dont know how to declare things...

     

    plz help me out....

  • What error are you getting?

    The script is a straight copy from one that is in use on our servers. 

    -------------------------------------------------------------------------
    Normal chaos will be resumed as soon as possible. :crazy:

  • hi mohammed,

     

    can you tell me how to run the sql commands in DTS Activex scripts?

     

    like the exec xp_cmdshell ----

  • can u tell me how to wripe sql command in DTS Activex

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply