moving data from one server using SELECT @cmd='move

  • I have a server where client will FTP some leads everyday. I have to move these leads to a different server. The client will upload the leads with this naming convention YYYYMMDD_test.csv

    I have a SP that moves the leads. A dts package that runs also everyday.

    SELECT @cmd='move \\servername\folder\folder\YYYYMMDD_test.csv \\servername\folder\folder\Export_test.csv'

    exec master.dbo.xp_cmdshell @cmd

    The question i have how do i get the leads right for everyday by there naming convention YYYYMMDD_test.csv

    If they upload leads like

    20091126_test.csv

    20091127_test.csv

    When i run the SP i need to get the correct csv file for that day

    SELECT @cmd='move \\servername\folder\folder\YYYYMMDD_test.csv \\servername\folder\folder\Export_test.csv'

    exec master.dbo.xp_cmdshell @cmd

  • select convert(varchar(8),getdate(),112)+'_test.csv'

    The statement above will produce the correct file name for today's date.

    What is "that day"? The file with today's date? The latest file? Or something else entirely?

    Please try to be a little more specific.

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

  • Thanks it worked. 🙂

Viewing 3 posts - 1 through 2 (of 2 total)

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