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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Create Folders using SQL table
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

16 Posts

Posted - 01/03/2013 :  15:50:06  Show Profile  Reply with Quote

I have filenames such as:


listed in a table called "Reports".

Is there a way to:

1. Create (X) number of random folder names in a table ("X" depends on how many file names I have in the table.
2. Use these names to create folders on the C: drive.
3. Place the files in their corresponding folders?


Edited by - ph1long on 01/03/2013 15:52:00

Flowing Fount of Yak Knowledge

6065 Posts

Posted - 01/03/2013 :  17:24:20  Show Profile  Reply with Quote
I assume you are asking for a programmatic solution?

1. sounds like you simply want to add rows in one table based on the rows in another table?
That is easy with t-sql.

2 and 3. These both involve interaction with the file system. The best way to do that is with either application code (ie .net app) or with integrated code solution (ie CLR). .net has Class libraries with functionality to perform these typs of things. (ie System.IO.FileInfo)

Be One with the Optimizer
Go to Top of Page

Very Important crosS Applying yaK Herder

52326 Posts

Posted - 01/04/2013 :  02:55:39  Show Profile  Reply with Quote
1 same as what TG suggested
2 and 3 you could use File System Task available in SSIS to create folders. the looping can be implemented by means of ForEachLoop task. Also files can be moved using Move File functionality in SSIS

Sample packages using File System Task and ForEachLoop can be found here

SQL Server MVP

Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000