Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Createing a folder in TSQL:

Author  Topic 

rookie_sql
Constraint Violating Yak Guru

443 Posts

Posted - 2008-11-18 : 07:05:01
Am trying to create aa folder so i can copy file into each week as part of a job step. The code runs ok for me but i don;t get a new folder any ideas why ?


use [master]
declare @MD varchar(100), @Path varchar(100),@wk_no varchar(2)
set @wk_no = datepart(wk,getdate())
--print @wk_no


SET @Path = 'E:\FlatFiles\BCP\Data\'
SET @MD = 'mkdir' + @Path +'WK' + @wk_no

EXEC xp_cmdshell @MD, no_output

sakets_2000
Master Smack Fu Yak Hacker

1472 Posts

Posted - 2008-11-18 : 07:38:50
Always easier to debug if you print your dynamic sql before you execute it. You had no space between mkdir and path.

use [master]
declare @MD varchar(100), @Path varchar(100),@wk_no varchar(2)
set @wk_no = datepart(wk,getdate())
--print @wk_no


SET @Path = 'E:\FlatFiles\BCP\Data\'
SET @MD = 'mkdir ' + @Path +'WK' + @wk_no
EXEC xp_cmdshell @MD, no_output

Go to Top of Page

rookie_sql
Constraint Violating Yak Guru

443 Posts

Posted - 2008-11-18 : 07:52:51
Thanks i would have never gotten that i did not know there had to be a space after the mkdir.

Thanks for your help sakets_2000
Go to Top of Page

sakets_2000
Master Smack Fu Yak Hacker

1472 Posts

Posted - 2008-11-18 : 08:23:46
quote:
Originally posted by rookie_sql

Thanks i would have never gotten that i did not know there had to be a space after the mkdir.

Thanks for your help sakets_2000



Np :)
Go to Top of Page
   

- Advertisement -