newbieal
asked on
SQL Server 2005 job: move and copy file in DOS
How does one add a move and copy file dos command to a sql server job? And how does it record the date/time of the copy and move of the file?
I would think that you would have to do it either in SSIS as an Execute Process task, or using xp_cmdshell as a job step in the job. As for the 2nd question, I am not sure what you maen.
ASKER
I would need an actual example of the actual DOS command. I guess there are two involved, copy and move.
Also, to clarify my second question: I want there to be a date and time stamp for when the task of copying and moving a file in DOS was accomplished
Also, to clarify my second question: I want there to be a date and time stamp for when the task of copying and moving a file in DOS was accomplished
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Due to security measures on our system we are not allowed to use xp_cmdshell. Is there any other way to do this?
If you are using 2005 you could write some CLR procedures that move the file for you.
ASKER
could you give an example for clr procedure for my case?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
If we disregard the fact that I need to do this via sql server, how would the commands look if I would just do it in DOS directly?
copy c:\moveme.txt c:\tracefiles\moveme.txt
or
move c:\moveme.txt c:\tracefiles\moveme.txt
or
move c:\moveme.txt c:\tracefiles\moveme.txt
ASKER
what about the date stamp?
ASKER
I should clarify when we move then rename the file to include the date when the file was copied/moved, so:
move c:\moveme.txt c:\tracefiles\moveme022120 08.txt
move c:\moveme.txt c:\tracefiles\moveme022120
Is it OK to write the date out to a different file?
ASKER
not sure what you mean, can you give an example?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I get this error:
syntax of the command is incorrect
syntax of the command is incorrect
post your script
ASKER
I did this in dos using your command above, there is nothing else I can provide.
did you swap out the file names for a file on your c drive? Did you make sure you typed out all the little ~ and % characters correctly?
ASKER
yes, and I will double check - this works on your computer?
ASKER
after double-checking it worked. thanks!!