使用cmd重命名文件

时间:2019-01-16 12:00:02

标签: sql sql-server

我的代码如下所示,必须通过添加时间戳来重命名文件。

declare @timestamp nvarchar(20),@rename nvarchar(500)
set @timestamp= (select convert (nvarchar(16),getdate(),127))

 set @rename='RENAME \\girishc\fullshared\Girish\Export\test.xls test'+@timestamp+'.xls'
 EXEC master..xp_cmdshell @rename

它无法正常工作并得到

  

该进程无法访问该文件,因为该文件正在被另一个进程使用

能在这里帮我吗?

0 个答案:

没有答案
相关问题