Is there anyway to move and rename files without using xp_cmdshell??

Posted on 2007-03-20
Last Modified: 2013-11-30
I have created a couple of DTS that generate execl spreadsheets with data from production.  The problem is I need to archive these spreadsheets, rename them, move them to folders, etc, the problem is that I cant use xp_cmdshell to do so because of security reasons.  Our infrastructure support doenst want anyone use it since it is to powerful and creates to many security issues. Is there anyother way to do what I need to do with these files without using xp_cmdshell? Either using SQL, VB, etc.
Question by:LJordanMS
  • 2
  • 2
  • 2
LVL 10

Expert Comment

ID: 18760069
You can use an ActiveX Script task and FileSystemObject in DTS

Author Comment

ID: 18760086
I have never done that before, how do you do that? Is there a resource that I can look at to see how its done?
LVL 10

Accepted Solution

ksaul earned 250 total points
ID: 18760098
For example...
'create some string variables for the oldfile name and new file name
Set fso = CreateObject ("Scripting.FileSystemObject")
      If fso.FileExists (sPath & sOldFileName) Then
            fso.CopyFile sOldPath & sOldFileName, sNewPath  & sNewFileName
            fso.DeleteFile sOldPath & sOldFileName
      End if
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

LVL 16

Expert Comment

ID: 18761150
There is an execute process task that will take a Windows command and execute it. You can use it to run the copy or xcopy command to copy the files or any other executable.

Author Comment

ID: 18764353
How would you implement the execute process for xcopy using a DTS?
LVL 16

Expert Comment

ID: 18765173
The caveat to using Xcopy is you would have to know the name of the file you want to copy and where you want to copy it. Unless you can create a batch file to do the work

Add Execute Process Task to package
Win 32 process: xcopy.exe
Parameter:  file to copy and location, i.e. C:\somefile.xls c:\someotherlocation

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Deal with apostrophe in stored procedures 8 43
T-SQL:  Collapsing 9 25
SQL2016 to ORACLE11G linked-server 6 15
divide by zero error 23 16
Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question