on-internet
← Community

Move text file from one folder to another folder using SQL

Stack Overflow ·

I have been using the following SQL script to move files from one location to another: EXEC master.dbo.sp_configure 'show advanced options', 1 RECONFIGURE EXEC master.dbo.sp_configure 'xp_cmdshell', 1 RECONFIGURE DECLARE @cmd nvarchar(500), @folderName varchar(100), @move varchar(100), @destinationpath varchar(50) SET @folderName = 'Newfolder_' + REPLACE(CONVERT(varchar(10), GETDATE(), 101), '/', '') SET @cmd = 'mkdir C:\FileDestination\' + @folderName EXEC master..xp_cmdshell @cmd --- this will create folder(newfolder_mmddyyy) SET @destinationpath = 'C:\FileDestination\' + @folderName SET @mo

Comments

Sign in or sign up to comment and upvote.

No comments yet.