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

Copy and rename a file Expand / Collapse
Author
Message
Posted Monday, January 28, 2008 12:55 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, February 19, 2013 8:26 AM
Points: 7, Visits: 204
Hi,

I would like to copy a flat file from one location to another and rename it. Can i do it in a single step coz I need to execute it as a daily job. does xcopy support this.

Thanks in advance.

Madduri
Post #448531
Posted Monday, January 28, 2008 6:15 PM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Wednesday, January 08, 2014 2:49 PM
Points: 1,279, Visits: 2,203
try "copy c:\myfolder\myfile.txt d:\yourfolder\yourfile.txt".
Post #448648
Posted Wednesday, January 30, 2008 11:17 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, February 19, 2013 8:26 AM
Points: 7, Visits: 204
Thank you for your reply. I did it using ssis.

Thanks, Madduri
Post #449566
Posted Thursday, January 31, 2008 12:48 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Wednesday, April 16, 2014 4:45 AM
Points: 2,385, Visits: 1,843
SSIS might be expensive. Here is the simple way; create job and write following T-SQL command:

xp_cmdshell "copy c:\myfolder\myfile.txt d:\yourfolder\yourfile.txt"


---------------------------------------------------
"Thare are only 10 types of people in the world:
Those who understand binary, and those who don't."
Post #449833
Posted Thursday, January 31, 2008 4:19 AM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Monday, March 10, 2014 9:05 AM
Points: 421, Visits: 363
You can use CmdExec method (Using operating system command) also to run the command.
To Use the extended stored procedure xp_cmdShell, it needs to be enabled. By default it is disabled due to security concerns.

The Job Step will be some thing like this:
EXEC @ReturnCode = msdb.dbo.sp_add_jobstep @job_id=@jobId, @step_name=N'copy file',
@step_id=1,
@cmdexec_success_code=0,
@on_success_action=1,
@on_success_step_id=0,
@on_fail_action=2,
@on_fail_step_id=0,
@retry_attempts=0,
@retry_interval=0,
@os_run_priority=0,
@subsystem=N'CmdExec',
@command=N'ccopy c:\myfolder\myfile.txt d:\yourfolder\yourfile.txt'
,
@flags=0


Cheers,
Prithiviraj Kulasingham

http://preethiviraj.blogspot.com/
Post #449867
Posted Monday, March 17, 2008 2:05 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, May 01, 2008 10:14 AM
Points: 1, Visits: 5
How did you do it using SISS? I have been trying to figure this out and I am fine with the fact that it might be expensive, I am trying to do this with a very small data set.
Post #470484
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse