how to copy directory using sql server

DECLARE @Query VARCHAR(8000)
SET @Query = ‘xcopy “{Source  Directory Path}\*.*” “{Destination Directory Path}\” /e /i /h /y ‘
PRINT @Query
EXEC master.dbo.xp_cmdshell @Query

Where

  1. “*.*” Copy all directory and file in source path.
  2. “/e” Copies directories and sub directories, including empty ones. Same as /S /E. May be used to modify /T.
  3. “/i” If destination does not exist and copying more than one file, assumes that destination must be a directory.
  4. “/h” Copies hidden and system files also.
  5. “/y” Overwrites existing files without prompting.

Leave a Reply

Protected with IP Blacklist CloudIP Blacklist Cloud

Unable to load the Are You a Human PlayThru™. Please contact the site owner to report the problem.