Using xp_cmdshell , copy file on SQL Server have an folder name issue.
Example:
Wrong one: xp_cmdshell 'copy C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\mssqlsystemresource.mdf d:\temp'
Error: The above command will fail to execute it due to the folder naming convention and the spaces between folder names.(ex.Program Files and Microsoft SQL Server). So the solution for this is just put full path on double quote(") start and end.Then it works fine.
Correct one: xp_cmdshell 'copy "C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\mssqlsystemresource.mdf" d:\temp'
Example:
Wrong one: xp_cmdshell 'copy C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\mssqlsystemresource.mdf d:\temp'
Error: The above command will fail to execute it due to the folder naming convention and the spaces between folder names.(ex.Program Files and Microsoft SQL Server). So the solution for this is just put full path on double quote(") start and end.Then it works fine.
Correct one: xp_cmdshell 'copy "C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\mssqlsystemresource.mdf" d:\temp'
No comments:
Post a Comment