I'm usng SQL server and i want to rename a file using the xp_cmdshell.
here's my code:
declare @.path varchar (20)
declare @.filename varchar (20)
declare @.new varchar (20)
declare @.cmd varchar (20)
set @.path = 'E:\folder1\folder2\folder3\'
set @.filename = @.path+'filename.txt'
set @.new = 'newfilename.txt'
set @.cmd = 'REN '+@.filename+' '+@.new
exec master..xp_cmdshell @.cmd
--
after running, i get this error:
The syntax of the command is incorrect.
Need technical help. please advise asap.
thnx again.hi
i am not sure but i think u have to delclare another variable such as @.result and then
execute @.result=master..xp_cmdshell @.cmd
i hope it work|||This will help you. first declare the parameters and use the following code.
set @.backup_filePartialname = @.diff_backup_path+@.db_name + '_*.bak'
set @.backup_filename = @.db_name + '.bak'
set @.dos_cmd = 'RENAME ' + @.backup_filePartialname + ' ' + @.backup_filename
EXEC @.dos_result = master.dbo.xp_cmdshell @.dos_cmd, NO_OUTPUT
No comments:
Post a Comment