July 18, 2011 at 9:44 am
Please,
Is there any transact SQL Command which allows me to copy files from one folder to another on the same computer?
Thanks!
July 18, 2011 at 11:00 am
why would you want to do that using TSQL ??
Why would you want to make an in-transaction sql statement dependent on a file system copy ?
Can't you do it using a sqlagent job ?
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data/code to get the best help[/url]
- How to prevent a sore throat after hours of presenting ppt
press F1 for solution, press shift+F1 for urgent solution 😀
Need a bit of Powershell? How about this
Who am I ? Sometimes this is me but most of the time this is me
July 18, 2011 at 11:01 am
Beware the power and privilege of xp_cmdshell!
Adrian Nichols
Many Thoughts in a Storm
www.adriannichols.com
July 18, 2011 at 11:17 am
If your preference is T-SQL then you may wan't to check out these articles:
http://www.sqlservercentral.com/Forums/Topic538465-9-1.aspx
http://www.nigelrivett.net/SQLAdmin/s_nrSyncDir.html
For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
July 18, 2011 at 11:58 am
abdielmomo (7/18/2011)
Please,Is there any transact SQL Command which allows me to copy files from one folder to another on the same computer?
Thanks!
I would recommend PowerShell for this task. Chances are it's a one-liner.
There are no special teachers of virtue, because virtue is taught by the whole community.
--Plato
July 18, 2011 at 12:32 pm
There was a post on SSC of an example of the file copy using Powershell about a week ago.
For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
July 19, 2011 at 1:02 am
Welsh Corgi (7/18/2011)
There was a post on SSC of an example of the file copy using Powershell about a week ago.
# copy all jpg files from c:\temp to c:\temp\jpgs
Copy-Item -Path c:\temp\*.jpg c:\temp\jpgs
--> lines starting with # are comment lines
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data/code to get the best help[/url]
- How to prevent a sore throat after hours of presenting ppt
press F1 for solution, press shift+F1 for urgent solution 😀
Need a bit of Powershell? How about this
Who am I ? Sometimes this is me but most of the time this is me
July 21, 2011 at 11:57 am
In fact, I want to copy files from one folder to another when a new row is inserted in a table.
July 21, 2011 at 12:03 pm
abdielmomo (7/21/2011)
In fact, I want to copy files from one folder to another when a new row is inserted in a table.
If you are saying that you want the file copy to happen real-time, as is within a trigger, then I would strongly recommend against that approach. By coupling a file system operation with a database transaction you're signing up for tons of trouble.
A better approach, albeit with it's own issues, would be to have a process poll the table in question and do the file copy as a secondary process.
If you need a guarantee that the file copy will occur as part of the same unit of work, but on a separate thread that will not hold up the database transaction from completing, then I would recommend you look into using Service Broker to add a row to a queue and then have the broker activate a process to the file copy and handle the rollback of data in the database should the file copy fail.
There are no special teachers of virtue, because virtue is taught by the whole community.
--Plato
July 21, 2011 at 12:17 pm
opc.three (7/21/2011)
abdielmomo (7/21/2011)
In fact, I want to copy files from one folder to another when a new row is inserted in a table.If you are saying that you want the file copy to happen real-time, as is within a trigger, then I would strongly recommend against that approach. By coupling a file system operation with a database transaction you're signing up for tons of trouble.
A better approach, albeit with it's own issues, would be to have a process poll the table in question and do the file copy as a secondary process.
If you need a guarantee that the file copy will occur as part of the same unit of work, but on a separate thread that will not hold up the database transaction from completing, then I would recommend you look into using Service Broker to add a row to a queue and then have the broker activate a process to the file copy and handle the rollback of data in the database should the file copy fail.
+1
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data/code to get the best help[/url]
- How to prevent a sore throat after hours of presenting ppt
press F1 for solution, press shift+F1 for urgent solution 😀
Need a bit of Powershell? How about this
Who am I ? Sometimes this is me but most of the time this is me
July 21, 2011 at 3:32 pm
Count this as another vote for opc.three's solution.
+1
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills
July 21, 2011 at 3:35 pm
The Dixie Flatline (7/21/2011)
Count this as another vote for opc.three's solution.+1
+2
For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
July 21, 2011 at 3:41 pm
ALZDBA (7/19/2011)
Welsh Corgi (7/18/2011)
There was a post on SSC of an example of the file copy using Powershell about a week ago.
# copy all jpg files from c:\temp to c:\temp\jpgs
Copy-Item -Path c:\temp\*.jpg c:\temp\jpgs
--> lines starting with # are comment lines
BWAA-HAAA!!!! What's wrong with DOS??? 😛
COPY c:\temp\*.jpg c:\temp\jpgs
--Jeff Moden
Change is inevitable... Change for the better is not.
July 21, 2011 at 3:46 pm
Jeff Moden (7/21/2011)
ALZDBA (7/19/2011)
Welsh Corgi (7/18/2011)
There was a post on SSC of an example of the file copy using Powershell about a week ago.
# copy all jpg files from c:\temp to c:\temp\jpgs
Copy-Item -Path c:\temp\*.jpg c:\temp\jpgs
--> lines starting with # are comment lines
BWAA-HAAA!!!! What's wrong with DOS??? 😛
COPY c:\temp\*.jpg c:\temp\jpgs
'
DOS is too simple. 😀
For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
July 21, 2011 at 9:16 pm
Jeff Moden (7/21/2011)
...BWAA-HAAA!!!! What's wrong with DOS??? 😛
...
Heh...I'll assume that was a rhetorical question 😛
There are no special teachers of virtue, because virtue is taught by the whole community.
--Plato
Viewing 15 posts - 1 through 15 (of 21 total)
You must be logged in to reply to this topic. Login to reply