I got the solution from one of my colleagues
Please find the solution below
DECLARE @from VARCHAR(200)
DECLARE @to VARCHAR(200)
DECLARE @to_move VARCHAR(200)
DECLARE @sql VARCHAR(200)
DECLARE @sql_mov VARCHAR(200)
DECLARE @sql_del VARCHAR(200)
SELECT @to = '\\X\20120724.txt',
@from = '\\Y\20120724.txt',
@to_move = '\\Z\20120724.txt'
SET @sql = 'copy ' + @from + ' ' + @to
SET @sql_mov = 'copy ' + @from + ' ' + @to_move
SET @sql_del = 'del ' + @from
EXECUTE master..xp_cmdshell @sql
EXECUTE master..xp_cmdshell @sql_mov
EXECUTE master..xp_cmdshell @sql_del
If you're going to use xp_CmdShell for this, there is a MOVE command in DOS and in ROBOCOPY.
is pronounced ree-bar and is a Modenism for R
First step towards the paradigm shift of writing Set Based code: Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column.
Although they tell us that they want it real bad, our primary goal is to ensure that we dont actually give it to them that way.
Although change is inevitable, change for the better is not.
Just because you can do something in PowerShell, doesnt mean you should. Helpful Links:
How to post code problemsHow to post performance problemsForum FAQs