How to create directory in SQL with Space
-
Hello, I am able to create a directory by using sql as Exec master.dbo.xp_cmdshell 'C:\MyTest\<>' but when I tried to create director name with space as Exec master.dbo.xp_cmdshell 'C:\My Test'\<> then its throwing error. can anybody please help me how to create directory with space in SQL
Samar
-
Hello, I am able to create a directory by using sql as Exec master.dbo.xp_cmdshell 'C:\MyTest\<>' but when I tried to create director name with space as Exec master.dbo.xp_cmdshell 'C:\My Test'\<> then its throwing error. can anybody please help me how to create directory with space in SQL
Samar
Surround the directory string with double quotes
========================================================= I'm an optoholic - my glass is always half full of vodka. =========================================================
-
Surround the directory string with double quotes
========================================================= I'm an optoholic - my glass is always half full of vodka. =========================================================
Thank you very much for your reply but I already did as Exec master.dbo.xp_cmdshell '"C:\Temp\My Test "' but still getting facing problem
Samar
-
Hello, I am able to create a directory by using sql as Exec master.dbo.xp_cmdshell 'C:\MyTest\<>' but when I tried to create director name with space as Exec master.dbo.xp_cmdshell 'C:\My Test'\<> then its throwing error. can anybody please help me how to create directory with space in SQL
Samar
Samarjeet Singh@india wrote:
Exec master.dbo.xp_cmdshell 'C:\My Test'\<<DATE>> then its throwing error.
What's that? always include those details in your question.
thatraja
Please update this article Useful Reference Books, it's urgent for Q/A section
-
Samarjeet Singh@india wrote:
Exec master.dbo.xp_cmdshell 'C:\My Test'\<<DATE>> then its throwing error.
What's that? always include those details in your question.
thatraja
Please update this article Useful Reference Books, it's urgent for Q/A section
For example if I tried to run in sql Exec master.dbo.xp_cmdshell '"C:\Temp\My Test"' Then I am getting following 3 rows of messages 1- 'C:\Temp\My' is not recognized as an internal or external command 2-operable program or batch file. 3- NULL Thanks
-
Hello, I am able to create a directory by using sql as Exec master.dbo.xp_cmdshell 'C:\MyTest\<>' but when I tried to create director name with space as Exec master.dbo.xp_cmdshell 'C:\My Test'\<> then its throwing error. can anybody please help me how to create directory with space in SQL
Samar
You need to use
xp_create_subdir
, notxp_cmd_shell
: http://www.mssqltips.com/sqlservertip/1460/sql-server-script-to-create-windows-directories/[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
You need to use
xp_create_subdir
, notxp_cmd_shell
: http://www.mssqltips.com/sqlservertip/1460/sql-server-script-to-create-windows-directories/[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
Thank u very much !!!!! its working in sql2008 but client is running in older version(Sql2000) and in older version its unable to find the reference and producing following msg
Server: Msg 2812, Level 16, State 62, Line 1
Could not find stored procedure 'master.dbo.xp_create_subdir'.is any other method so that its working in SQL2000 as well Thanks in advance
-
Thank u very much !!!!! its working in sql2008 but client is running in older version(Sql2000) and in older version its unable to find the reference and producing following msg
Server: Msg 2812, Level 16, State 62, Line 1
Could not find stored procedure 'master.dbo.xp_create_subdir'.is any other method so that its working in SQL2000 as well Thanks in advance
For SQL 2000, you'll need to stick with
xp_cmdshell
, but you need to putmkdir
in front of the path you want to create:Exec master.dbo.xp_cmdshell 'mkdir "C:\My Test\<>"'
http://www.sqlservercentral.com/Forums/Topic604168-8-1.aspx[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
Hello, I am able to create a directory by using sql as Exec master.dbo.xp_cmdshell 'C:\MyTest\<>' but when I tried to create director name with space as Exec master.dbo.xp_cmdshell 'C:\My Test'\<> then its throwing error. can anybody please help me how to create directory with space in SQL
Samar
-
Hello, I am able to create a directory by using sql as Exec master.dbo.xp_cmdshell 'C:\MyTest\<>' but when I tried to create director name with space as Exec master.dbo.xp_cmdshell 'C:\My Test'\<> then its throwing error. can anybody please help me how to create directory with space in SQL
Samar
below procedure should be the solution create procedure sp_create_directory ( @full_path varchar(500) ) as set nocount on declare @command varchar(1000) set @command = 'mkdir ' + @full_path exec master..xp_cmdshell @command , no_output set nocount off GO
-
For SQL 2000, you'll need to stick with
xp_cmdshell
, but you need to putmkdir
in front of the path you want to create:Exec master.dbo.xp_cmdshell 'mkdir "C:\My Test\<>"'
http://www.sqlservercentral.com/Forums/Topic604168-8-1.aspx[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
Thank you very much it working for me
-
below procedure should be the solution create procedure sp_create_directory ( @full_path varchar(500) ) as set nocount on declare @command varchar(1000) set @command = 'mkdir ' + @full_path exec master..xp_cmdshell @command , no_output set nocount off GO
Thanks for your great help