Home Forums SQL Server 7,2000 General Copy and rename a file using stored procedure in SQL server 2005 RE: Copy and rename a file using stored procedure in SQL server 2005

  • Hi..

    May be this would help:

    First of all..make sure that the filename has no spaces

    then.. enable xp_cmdshell if its disabled using:

    EXEC sp_configure 'show advanced options', 1

    GO

    RECONFIGURE

    EXEC sp_configure 'xp_cmdshell', 1

    GO

    RECONFIGURE

    go

    then if u want to copy files.. use copy command:

    eg here I am copying all files starting with kss in the input folder to a file called kssdatasource in the datasource folder(/B is for binary,/Y for replace existing file):

    EXEC master..xp_cmdshell 'COPY /Y E:\Interface\Truck_Scale_Interface\Input\kss* /B E:\Interface\Truck_Scale_Interface\Datasource\kssdatasource.csv'

    If u want to Move files.. u can use 'Move' instead..