Nem*_*emo 7 t-sql sql-server sql-server-2008
我在目录中有一个文件 \\myServer\Admin\temp\testtemp.txt
我需要写一个TSQL
testtemp.txt文件.Copytesttemp.txt如果testtemp.txt已经在上面这样的目录中
\\abcd\Admin\temp\Copytesttemp.txt
Run Code Online (Sandbox Code Playgroud)然后删除它并重新创建 Copytesttemp.txt
我该如何实现?谢谢.
Pau*_*aul 17
您可以使用xp_cmdshell运行您喜欢的任何DOS命令,例如
declare @cmdstring varchar(1000)
set @cmdstring = 'copy \\myServer\Admin\temp\testtemp.txt \\myServer\Admin\temp\Copytesttemp.txt'
exec master..xp_cmdshell @cmdstring
Run Code Online (Sandbox Code Playgroud)
只需确保在您的安装上启用了xp_cmdshell.