Home Forums SQL Server 7,2000 General Rename a text file, move it, using a stored procedure RE: Rename a text file, move it, using a stored procedure

  • does this work for you? i just put the commadn into a string and caled the shell with the variable.

    DECLARE

    @TodayDate as varchar(40),

    @TodayHour as varchar(40),

    @TodayMinu  as varchar(40),

    @NewFileName as varchar(100),

    @cmdstr as varchar(128)

    SELECT @TodayDate = CONVERT(varchar(10), GETDATE(), 112)

    SELECT @TodayHour = DATEPART(hh,GETDATE())

    SELECT @TodayMinu = DATEPART(mi,GETDATE())

    SELECT @NewFileName = 'ImportData' + '_' + @TodayDate + '_' + @TodayHour + '_' + @TodayMinu + '.txt'

    print @NewFileName

    set @cmdstr='MOVE /Y C:\ImportData\ImportData.txt C:\ImportData\Finished\'  + @NewFileName 

    print @cmdstr

    EXEC master..xp_cmdshell @cmdstr

     

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!