executing dos commands

  • Hi all, I have to copy specific files from one folder to another. The name is in plain text in the database and the path can be constructed from other pieces of data. If I were to make a table containing the source and destination what sql tool would I use to perform the copy. Thank you and warm regards.

  • You can either write a batch script to get the required information from the database via a command line, or if you want to do from within the database you can use master.dbo.xp_cmdshell.

    Note: This External Stored Procedure is disabled on many databases as it can be considered a security risk.

    James Leeper

    Database Administrator

    WDS Global - Americas Region

    James Leeper
    Database Administrator
    WDS Global - Americas Region

  • I would recommend VBSCript to do this. The FileSystemObject can perform file manipulation and the ADO objects can connect to SQL Server.

    http://www.mssqltips.com/tip.asp?tip=1324

  • Depending on your level of comfort with the DOS gods, I'd recommend either xp_CmdShell or SSIS. If you were to post a wee bit more information using the techinques found in the article at the first link in my signature line below, I'm betting a bunch of folks could give you working suggestions.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply