Home Forums SQL Server 7,2000 General Copy and rename a file using stored procedure in SQL server 2005 RE: Copy and rename a file using stored procedure in SQL server 2005

  • Jeff Moden - Saturday, February 4, 2017 11:47 AM

    anilkumarg 33214 - Friday, February 3, 2017 4:03 PM

    Jeff Moden - Saturday, August 16, 2008 7:57 PM

    You CAN have file names with spaces (although, I prefer not to). And, you can easily run commands on those file names by enclosing the filename in double quotes... like this...EXEC master..xp_cmdshell 'RENAME "C:\Webservices\datasource\TradeDetail04-02-08 00_00_00 .txt" TradeDetail.txt'

    Hi How do change the Date modified on a file using XP_CMDSHELL COPY Sourcefile to Destination File

    In general, the file would have to be modified and a COPY doesn't modify the file.  Neither does a RENAME  There is a way to do it but I've forgotten... it was almost 35 years ago when I did such a thing and haven't had to do the same since then.  Perhaps a visit to Yabingoolehoo would be worthwhile on that subject.

    It's been a while, but I believe there's a Windows port of an old Unix command called touch.  When you touch a file, you update the last modified date and time.  IIRC, it's a simple copy/paste of the touch executable and then you can use it.  I've not tested it with any of the OSes past Windows XP or Windows 2000.

    HTH