August 27, 2011 at 8:45 am
Hi All,
How to loop through files in a specified folder, load one by one from source folder and copy to destination folder using SQL stored procedure.
My requirement is, I want to create a SP and which will copy file by file from source folder to destination folder. And before copy I need to check the the file exists in destination folder. If the file is there already so i don't want to copy that file again.
Please help me on this
Note: My client doesn't want to use SSIS.
Regards
Saratah Babu Vellampalli.
Kindest Regards,
Sarath Vellampalli
August 27, 2011 at 12:21 pm
Why would you be required to do this from SQL Server? This is much better handled outside of SQL Server using any number of techniques.
My preference for something like this would be Robocopy and either a Powershell script or a DOS batch scripts to copy the files from one location to another.
There are other options...
If this absolutely must be done with a stored procedure, the only difference to the above options is that you have to enable xp_cmdshell and call out to those batch scripts or execute the commands directly.
The other option would be to use a SQL Server agent job - and execute the commands using the operating system command system.
Jeffrey Williams
“We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”
― Charles R. Swindoll
How to post questions to get better answers faster
Managing Transaction Logs
August 27, 2011 at 4:18 pm
Sarath Vellampalli (8/27/2011)
Hi All,How to loop through files in a specified folder, load one by one from source folder and copy to destination folder using SQL stored procedure.
My requirement is, I want to create a SP and which will copy file by file from source folder to destination folder. And before copy I need to check the the file exists in destination folder. If the file is there already so i don't want to copy that file again.
Please help me on this
Note: My client doesn't want to use SSIS.
Regards
Saratah Babu Vellampalli.
Lookup "XCOPY" in Windows help. And, no, it won't need to be done from a stored proc. It can be done through a sheduled job.
--Jeff Moden
Change is inevitable... Change for the better is not.
August 27, 2011 at 5:25 pm
Just note that XCOPY has been deprecated in Windows Vista and Windows Server 2008 and above.
The replacement is Robocopy - according to the help if you run XCOPY /? on one of those systems.
I just checked on my Windows 7 box - and I don't get the deprecated message, which is interesting but I would still recommend Robocopy over XCOPY because of it's greater flexibility.
If you don't have a copy and are on one of the older OS's, it is included in the Windows Resource Kit for that OS.
Jeffrey Williams
“We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”
― Charles R. Swindoll
How to post questions to get better answers faster
Managing Transaction Logs
August 27, 2011 at 6:37 pm
Yeah, you're right, of course. Old habits die hard.
--Jeff Moden
Change is inevitable... Change for the better is not.
August 28, 2011 at 10:03 am
Jeff Moden (8/27/2011)
Yeah, you're right, of course. Old habits die hard.
And us old dogs have a much harder time learning new tricks...:w00t:
Jeffrey Williams
“We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”
― Charles R. Swindoll
How to post questions to get better answers faster
Managing Transaction Logs
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply