I have a file inside a directory \\myServer\Admin\temp\testtemp.txt
I need to write a TSQL to
testtemp.txt
file.Copytesttemp.txt
If there's testtemp.txt
already in the above directory like this
\\abcd\Admin\temp\Copytesttemp.txt
then delete it and recreate Copytesttemp.txt
How do I achieve it? Thanks.
You can use xp_cmdshell to run any DOS commands you like, e.g.
declare @cmdstring varchar(1000)
set @cmdstring = 'copy \\myServer\Admin\temp\testtemp.txt \\myServer\Admin\temp\Copytesttemp.txt'
exec master..xp_cmdshell @cmdstring
Just make sure xp_cmdshell is enabled on your installation.
Create a SQL Agent job which runs a command script to do the actions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With