Starting with SQL Server 2005 xp_cmdshell is turned off by default as a security measure. You have to explicitly enable xp_cmdshell it. If you have to move files around on a SQL Server box there are probably better ways than using xp_cmdshell, you can use SSIS, powershell, plain old DOS. But old habits are difficult to break and maybe you have ton of legacy code. Someone asked how to supress output from xp_cmdshell when moving a file
I you move a file with xp_cmdshell, you will get the following output
1 file(s) moved.
If I want to move a file from c:\temp to c:\temp\old, I would execute the following
- xp_cmdshell 'move c:\temp\bla.txtc:\temp\old\bla.txt'
Here is what it looks like in SSMS
As you can see you get a resultset, in order to surpress that, you can add no_output to the xp_cmdshell call, no_output is an optional parameter, specifying that no output should be returned to the client.
Here is what the command looks like
- xp_cmdshell 'move c:\temp\bla.txt c:\temp\old\bla.txt',no_output
Executing the command like that will not return a resultset anymore