Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Running xcopy commend from Select Statement Expand / Collapse
Author
Message
Posted Thursday, May 16, 2013 11:27 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Thursday, September 4, 2014 7:39 AM
Points: 91, Visits: 214
select
OrderNum,
OrderLine,
OrderRelease
FileTemplateName
from OrderLines

I would like to run a xcopy statement for each record and copy the file from FileTemplateName to
c:\OrderFiles\<OrderNUm>\<OrderLine>\<OrderRelease>\<OrderNum>_<OrderLine>_<OrderRelease>_FileTemplateName
Post #1453701
Posted Thursday, May 16, 2013 1:13 PM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 11:26 AM
Points: 13,436, Visits: 12,299
skb 44459 (5/16/2013)
select
OrderNum,
OrderLine,
OrderRelease
FileTemplateName
from OrderLines

I would like to run a xcopy statement for each record and copy the file from FileTemplateName to
c:\OrderFiles\<OrderNUm>\<OrderLine>\<OrderRelease>\<OrderNum>_<OrderLine>_<OrderRelease>_FileTemplateName


I am guessing that what you have is just the file name stored in the database and you want to make a physical copy of the existing file in the new location? Are these files in the directory on the sql server or another server? If they are on the same server I would think you could do this with CLR fairly easily. If they are on another server this could get pretty tricky.


_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1453751
Posted Thursday, May 16, 2013 1:16 PM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Thursday, September 4, 2014 7:39 AM
Points: 91, Visits: 214
I am guessing that what you have is just the file name stored in the database and you want to make a physical copy of the existing file in the new location?
Yes
Are these files in the directory on the sql server or another server?
Other File server
Post #1453753
Posted Thursday, May 16, 2013 1:20 PM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 11:26 AM
Points: 13,436, Visits: 12,299
skb 44459 (5/16/2013)
I am guessing that what you have is just the file name stored in the database and you want to make a physical copy of the existing file in the new location?
Yes
Are these files in the directory on the sql server or another server?
Other File server


OK so is this a one time thing or do you need to do this repeatedly?


_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1453755
Posted Thursday, May 16, 2013 1:22 PM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Thursday, September 4, 2014 7:39 AM
Points: 91, Visits: 214
Its going to be ondemand . I am going to create a stored procedure for it and the select statement will have a where clause (Parameters).
Post #1453757
Posted Thursday, May 16, 2013 1:25 PM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 11:26 AM
Points: 13,436, Visits: 12,299
skb 44459 (5/16/2013)
Its going to be ondemand . I am going to create a stored procedure for it and the select statement will have a where clause (Parameters).


Can you post ddl and a few rows of sample data?


_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1453760
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse