Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2004
    Posts
    2

    Unanswered: File Manipulation from MS SQL Server

    I am working on an application which uses DTS to move data into temporary tables. I would like to be able to rename/relocate the source file in order to maintain a historical reference. The process which creates the source file is not flexible at all. Is there a way to manipulate the file's name and/or relocate the file by using SQL Server.

    Thanks in advance!

    Daniel
    Austin, Texas

  2. #2
    Join Date
    May 2004
    Posts
    125
    Try looking into xp_cmdshell stored proc in BOL. This will allow you to use DOS commands from a TSQL script. We had to use this stored proc to rename delimited files we created from a DTS to be exported to a marketing company. Works pretty good.

    HTH

    DMW

  3. #3
    Join Date
    Apr 2004
    Posts
    2
    Hi DMW,

    Thank you very much! I will give this a try.

    Sincerely,

    Daniel
    Austin, Texas

  4. #4
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Code:
    USE Northwind
    GO
    
    SET NOCOUNT ON
    CREATE TABLE myTable99(RowNum int IDENTITY(1,1), Data varchar(8000))
    GO
    
    INSERT INTO myTable99(Data) EXEC master..xp_cmdshell 'Dir C:\*.*'
    
    SELECT * FROM myTable99
    GO
    
    SET NOCOUNT OFF
    DROP TABLE myTable99
    GO
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  5. #5
    Join Date
    Jul 2003
    Location
    San Antonio, TX
    Posts
    3,662
    I use sp_oaxxx with FileSystemObject, because xp_cmdshell will require for a user to have privileges on the target file system.
    "The data in a record depends on the Key to the record, the Whole Key, and
    nothing but the Key, so help me Codd."

Posting Permissions

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