October 21, 2015 at 6:40 am
I have the following code below that I need help with:
EXEC
master.dbo.sp_configure 'show advanced options', 1
RECONFIGURE
EXEC
master.dbo.sp_configure 'xp_cmdshell', 1
RECONFIGURE
declare @FileName varchar(max), @FilePath varchar(max), @FullPath varchar(max), @destPath varchar(max), @destFileName varchar(max),
@destFullPath varchar(max), @move varchar(max)
SET @FilePath = '\\164.43.10.23\global$\Price_List_Files\run_sql\'
SET @FileName = Left(CONVERT(VARCHAR(10),GETDATE(),120),10) + '_All.txt'
SET @FullPath = @FilePath + @FileName
SET @destPath = '\\164.43.10.23\global$\Price_List_Files\completed_drop\_SQL-file-Archive\'
SET @destFileName = replace(CONVERT(VARCHAR(8),GETDATE(),108),':','')
Set @destFullPath = @destPath + substring(@FileName,1,len(@FileName) - 4) + '_imported_' + @destFileName + '.txt'
set @move ='move /Y' + @FullPath + ' /B ' + @destFullPath
exec master.dbo.xp_cmdshell @move
but i get the following error:
Msg 214, Level 16, State 201, Procedure xp_cmdshell, Line 1
Procedure expects parameter 'command_string' of type 'varchar'.
Any ideas???
October 21, 2015 at 8:19 am
I figured it out incase anyone wants to do the same:
declare @FileName varchar(1000), @FilePath varchar(1000), @FullPath varchar(1000), @destPath varchar(1000), @destFileName varchar(1000),
@destFullPath varchar(1000), @move varchar(1000)
SET @FilePath = '\\164.43.10.23\global$\Price_List_Files\run_sql\'
SET @FileName = Left(CONVERT(VARCHAR(10),GETDATE(),120),10) + '_All.txt'
SET @FullPath = @FilePath + @FileName
SET @destPath = '\\164.43.10.23\global$\Price_List_Files\completed_drop\_SQL-file-Archive\'
SET @destFileName = replace(CONVERT(VARCHAR(8),GETDATE(),108),':','')
Set @destFullPath = @destPath + substring(@FileName,1,len(@FileName) - 4) + '_imported_' + @destFileName + '.txt'
set @move ='move ' + @FullPath + ' '+ @destFullPath
exec master..xp_cmdshell @move
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply