使用xp_cmdshell创建文件夹 [英] Creating Folder using xp_cmdshell
本文介绍了使用xp_cmdshell创建文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Hi All:
I am trying to create folder using xp_cmdshell it works fine...But the problem is I cant consider a space char
in my folder name (i.e., Folder Name) the below script i used for .... It just create a folder ABC..
Why it's not create the folder with the full name i.e.,
ABC 1-X
...I don't know why.
--EXEC spCreateF0lder 'C:\ComName\Test\' ,'ABC X-1'
CREATE PROCEDURE spCreateF0lder
@DefaultPath varchar(MAX)
,@FolderName VARCHAR(100)
AS
BEGIN
DECLARE @SqlScript VARCHAR (MAX)
SET @SqlScript = 'EXEC master.dbo.xp_cmdshell ''' + 'mkDir ' + @DefaultPath + @FolderName + ''''
EXEC @SqlScript
Print @SqlScript
END
GO
推荐答案
在路径的两边加上双引号...如下所示......
put double quotations on the both sides of the path...like below...
EXEC
master 。 dbo 。 xp_cmdshell
'mkDir" c:\ Test2 test"'
master.dbo.xp_cmdshell ' mkDir "c:\Test2 test"'
谢谢,
Jahedur Rahman
这篇关于使用xp_cmdshell创建文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文