Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2003
    Posts
    83

    Unanswered: Renaming a local file

    Suppose I have an Excel file in D:\Test with the name a.xls.
    Can I rename that excel file from QA of SQL SERVER in the same location or any other location?
    Subhasish

  2. #2
    Join Date
    Jan 2004
    Location
    Sacramento, CA
    Posts
    5

    Talking

    You can perform any dos commands via SQL using xp_cmdshell. You must ensure the SQL server has permissions to the location where the file resides if that location is not on the SQL server.

    From QA type:

    xp_cmdshell 'rename D:\Test.xls Test2.xls'

    That should do the trick.

    -Lee
    MS SQL 2000 dba
    Verizon Wireless

  3. #3
    Join Date
    Sep 2003
    Location
    New York, NY
    Posts
    136
    you might even have an activex task to do this in your DTS package. Here is the code
    ======================================
    Function Main()
    Dim fs, MyFile
    Dim FileLocation
    Dim FileName
    Dim FileInfo

    FileLocation = "D:\Test\"
    FileName = "a.xls"
    FileInfo = FileLocation & FileName

    Set fs = CreateObject("Scripting.FileSystemObject")

    If (fs.FileExists(FileInfo)) Then
    fs.MoveFile (FileInfo),(FileLocation & "new_name.xls")
    set fs=nothing
    Main = DTSTaskExecResult_Success
    exit function
    Else
    Main = DTSTaskExecResult_Failure
    exit function
    End If

    End Function
    ===========================================

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •