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)
 problem with folder creation

Author  Topic 

sqllearner
Aged Yak Warrior

639 Posts

Posted - 2004-10-04 : 12:33:40
Hi all,
Iam facing a problem where I have to create folders according to a list of ids..eg:
emp_id
101
102
103
178
Here according to the list of emp_id from emp_detail table I have to create folders for each Id and validate if the same folder present then should not create else I should create folder to a specified directory say D:\EMP

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-10-04 : 13:49:56
So what code are you using and what is the error? And you do know that the folder would be created on the database server if you use SQL Server to do this?

Tara
Go to Top of Page

sqllearner
Aged Yak Warrior

639 Posts

Posted - 2004-10-04 : 14:37:26
Tara if the folder is created in the database server then I may write some vb appication to store to a local drive..Thanks tara...
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2004-10-04 : 16:49:06
Or just connect the server to the location and create them that way...



Brett

8-)
Go to Top of Page

jen
Master Smack Fu Yak Hacker

4110 Posts

Posted - 2004-10-05 : 00:03:27
you can explore cmdexec, which i found really awesome, since i like having a contingency plan in case the default drive gets corrupted.
you can create folders on local or network drives
Go to Top of Page

Shurgenz
Yak Posting Veteran

51 Posts

Posted - 2004-10-05 : 04:50:45
try xp_cmdshell

DECLARE @result int
EXEC @result = xp_cmdshell 'dir D:\EMP\somewhat'
IF (@result = 0)
PRINT 'Success' --not need to create
ELSE
exec xp_cmdshell 'md D:\EMP\somewhat'
Go to Top of Page

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2004-10-05 : 08:44:01
remember xp_cmdshell runs with SQL privilages and may (should) be locked down/out from use by regular users.
Go to Top of Page

Shurgenz
Yak Posting Veteran

51 Posts

Posted - 2004-10-05 : 08:52:01
aha... it is very dangerous sp. Via xp_cmdshell you can even format disk C on the server.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-10-05 : 12:22:56
But he needs the directories created on the client machine not on the database server.

Tara
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2004-10-05 : 12:24:29
quote:
Originally posted by tduggan

But he needs the directories created on the client machine not on the database server.

Tara



So....can't they use NET commands to connect to a different location and create them there..assuming security, ect...



Brett

8-)
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-10-05 : 12:27:23
Sure, but that certainly shouldn't be done inside SQL Server using xp_cmdshell. This is a job for the application not a stored procedure.

Tara
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2004-10-05 : 12:47:22
Why?

I've never done that...BUT, I have managed directories/files on the box itself...

Brett

8-)
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-10-05 : 12:48:53
Why would you do client side stuff at the database server level?

Tara
Go to Top of Page

Shurgenz
Yak Posting Veteran

51 Posts

Posted - 2004-10-06 : 01:05:09
I suppose, the folder creation, wich depends on data - is the server task, not client.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-10-06 : 12:31:51
Not when the folder is supposed to be created on the client.

Tara
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2004-10-06 : 13:17:09
quote:
Originally posted by tduggan

Not when the folder is supposed to be created on the client.

Tara



I assumed it was on another file server...not a client...

So I can see how that would be messy



Brett

8-)
Go to Top of Page
   

- Advertisement -